text:
from logging import getLogger

# import for the PyQt5 Framework
import PyQt5.QtWidgets
# numerics
import numpy
# matplotlib
from matplotlib import use

from analyse import analysedata
from baseclasses.widget import MwWidget
from gui import analyse_dialog_ui

use('Qt5Agg')
from matplotlib import pyplot as plt
from matplotlib import figure as figure
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas

class ShowAnalyseData(FigureCanvas):

    def __init__(self, parent=None):
        self.fig = figure.Figure(dpi=75, facecolor=(25/256, 25/256, 25/256))
        # self.axes = self.fig.add_axes([0.1, 0.1, 0.8, 0.8])
        self.axes = self.fig.add_subplot(111)
        self.axes.grid(True, color='white')
        self.axes.set_facecolor((32/256, 32/256, 32/256))
        self.axes.tick_params(axis='x', colors='white')
        self.axes.tick_params(axis='y', colors='white')
        FigureCanvas.__init__(self, self.fig)
        self.setParent(parent)
        FigureCanvas.updateGeometry(self)

# noinspection PyTypeChecker
def calculateTimeConstant(x_time, y_value):
    timeconstant = 0
    # print(x_time)
    # print(y_value)
    x = 0
    y = 0
    return timeconstant, x, y

# noinspection PyUnresolvedReferences
class AnalyseWindow(MwWidget):
    logger = getLogger(__name__)

    def __init__(self, app):
        super(AnalyseWindow, self).__init__()
        self.app = app
        self.showStatus = False
        self.scaleRA = 10
        self.scaleDEC = 10
        self.scaleError = 10
        self.data = {}
        self.analyse = analysedata.Analyse(self.app)
        self.ui = analyse_dialog_ui.Ui_AnalyseDialog()
        self.ui.setupUi(self)
        self.initUI()
        self.ui.scalePlotDEC.valueChanged.connect(self.changedDECScale)
        self.ui.scalePlotRA.valueChanged.connect(self.changedRAScale)
        self.ui.scalePlotError.valueChanged.connect(self.changedPlotError)
        self.ui.btn_selectDecError.clicked.connect(self.showDecError)
        self.ui.btn_selectDecErrorDeviation.clicked.connect(self.showDecErrorDeviation)
        self.ui.btn_selectRaError.clicked.connect(self.showRaError)
        self.ui.btn_selectRaErrorDeviation.clicked.connect(self.showRaErrorDeviation)
        self.ui.btn_selectDecErrorAltitude.clicked.connect(self.showDecErrorAltitude)
        self.ui.btn_selectRaErrorAltitude.clicked.connect(self.showRaErrorAltitude)
        self.ui.btn_selectDecErrorAzimuth.clicked.connect(self.showDecErrorAzimuth)
        self.ui.btn_selectRaErrorAzimuth.clicked.connect(self.showRaErrorAzimuth)
        self.ui.btn_selectModelPointPolar.clicked.connect(self.showModelPointPolar)
        self.ui.btn_selectModelPointErrorPolar.clicked.connect(self.showModelPointErrorPolar)
        helper = PyQt5.QtWidgets.QVBoxLayout(self.ui.plot)
        self.plotWidget = ShowAnalyseData(self.ui.plot)
        helper.addWidget(self.plotWidget)
        self.initConfig()
        # self.show()
        self.setVisible(False)

    def initConfig(self):
        try:
            if 'ScalePlotRA' in self.app.config:
                self.ui.scalePlotRA.setValue(self.app.config['ScalePlotRA'])
            if 'ScalePlotDEC' in self.app.config:
                self.ui.scalePlotDEC.setValue(self.app.config['ScalePlotDEC'])
            if 'ScalePlotError' in self.app.config:
                self.ui.scalePlotError.setValue(self.app.config['ScalePlotError'])
            if 'AnalysePopupWindowPositionX' in self.app.config:
                self.move(self.app.config['AnalysePopupWindowPositionX'], self.app.config['AnalysePopupWindowPositionY'])
            if 'AnalysePopupWindowShowStatus' in self.app.config:
                self.showStatus = self.app.config['AnalysePopupWindowShowStatus']
        except Exception as e:
            self.logger.error('Item in config.cfg not be initialize, error:{0}'.format(e))
        finally:
            pass

    def storeConfig(self):
        self.app.config['AnalysePopupWindowPositionX'] = self.pos().x()
        self.app.config['AnalysePopupWindowPositionY'] = self.pos().y()
        self.app.config['AnalysePopupWindowShowStatus'] = self.showStatus
        self.app.config['ScalePlotRA'] = self.ui.scalePlotRA.value()
        self.app.config['ScalePlotDEC'] = self.ui.scalePlotDEC.value()
        self.app.config['ScalePlotError'] = self.ui.scalePlotError.value()

    def showAnalyseWindow(self):
        self.getData()
        self.setWindowTitle('Analyse:    ' + self.app.ui.le_analyseFileName.text())
        self.showDecError()
        self.showStatus = True
        self.setVisible(True)
        self.show()

    def changedDECScale(self):
        if self.getData():
            self.showDecError()

    def changedRAScale(self):
        if self.getData():
            self.showRaError()

    def changedPlotError(self):
        if self.getData():
            self.showModelPointErrorPolar()

    def getData(self):
        filename = self.app.ui.le_analyseFileName.text()
        if filename == '':
            return False
        self.scaleRA = self.ui.scalePlotRA.value()
        self.scaleDEC = self.ui.scalePlotDEC.value()
        self.scaleError = self.ui.scalePlotError.value()
        self.data = self.analyse.loadData(filename)
        return True

    def setFigure(self, projection=None):
        self.plotWidget.fig.clf()
        self.plotWidget.axes = self.plotWidget.fig.add_subplot(1, 1, 1, projection=projection)
        self.plotWidget.axes.grid(True, color='gray')
        self.plotWidget.axes.set_facecolor((32/256, 32/256, 32/256))
        self.plotWidget.axes.tick_params(axis='x', colors='white')
        self.plotWidget.axes.tick_params(axis='y', colors='white')

    def showDecError(self):
        if len(self.data) > 0:
            self.data = self.analyse.prepareData(self.data, self.scaleRA, self.scaleDEC)
        else:
            return
        self.setFigure()
        self.plotWidget.axes.set_xlabel('Number of Model Point', color='white')                                             # x axis
        self.plotWidget.axes.set_ylabel('DEC Error (arcsec)', color='white')                                                # y axis
        self.plotWidget.axes.set_title('DEC Error over Modeling\n ', color='white')                                         # title
        self.plotWidget.axes.set_xlim(0, len(self.data['Index']))
        self.plotWidget.axes.set_ylim(-self.scaleDEC, self.scaleDEC)                                                        # defining the scaling of the plot
        self.plotWidget.axes.plot(self.data['Index'], self.data['DecError'], color='black')                                 # Basic Data
        colors = numpy.asarray(['blue' if x > 180 else 'green' for x in self.data['Azimuth']])
        self.plotWidget.axes.scatter(self.data['Index'], self.data['DecError'], c=colors, s=50)
        self.plotWidget.draw()                                                                                # put the plot in the widget

    def showDecErrorDeviation(self):
        if len(self.data) > 0:
            self.data = self.analyse.prepareData(self.data, self.scaleRA, self.scaleDEC)
        else:
            return
        # timeconstant, x, y = calculateTimeConstant(self.data['sidereal_time'], self.data['decError'])
        self.setFigure()
        self.plotWidget.axes.set_xlabel('Number of Model Point', color='white')                                             # x axis
        self.plotWidget.axes.set_ylabel('DEC Error(arcsec)', color='white')                                                 # y axis
        self.plotWidget.axes.set_title('DEC Error referenced to 0 over Modeling\n ', color='white')                         # title
        self.plotWidget.axes.set_xlim(0, len(self.data['Index']))
        self.plotWidget.axes.set_ylim(-self.scaleDEC, self.scaleDEC)                                                        # defining the scaling of the plot
        decErrorDeviation = numpy.asarray(self.data['DecError'])
        self.plotWidget.axes.plot(self.data['Index'], decErrorDeviation - decErrorDeviation[0], color='black')              # Basic Data
        colors = numpy.asarray(['blue' if x > 180 else 'green' for x in self.data['Azimuth']])
        self.plotWidget.axes.scatter(self.data['Index'], decErrorDeviation - decErrorDeviation[0], c=colors, s=50)
        self.plotWidget.draw()                                                                                # put the plot in the widget

    def showRaError(self):
        if len(self.data) > 0:
            self.data = self.analyse.prepareData(self.data, self.scaleRA, self.scaleDEC)
        else:
            return
        self.setFigure()
        self.plotWidget.axes.set_xlabel('Number of Model Point', color='white')
        self.plotWidget.axes.set_ylabel('RA Error (arcsec)', color='white')
        self.plotWidget.axes.set_title('RA Error over Modeling\n ', color='white')
        self.plotWidget.axes.set_xlim(0, len(self.data['Index']))
        self.plotWidget.axes.set_ylim(-self.scaleRA, self.scaleRA)
        self.plotWidget.axes.plot(self.data['Index'], self.data['RaError'], color='black')                                   # Basic Data
        colors = numpy.asarray(['blue' if x > 180 else 'green' for x in self.data['Azimuth']])
        self.plotWidget.axes.scatter(self.data['Index'], self.data['RaError'], c=colors, s=50)
        self.plotWidget.draw()

    def showRaErrorDeviation(self):
        if len(self.data) > 0:
            self.data = self.analyse.prepareData(self.data, self.scaleRA, self.scaleDEC)
        else:
            return
        self.setFigure()
        self.plotWidget.axes.set_xlabel('Number of Model Point', color='white')
        self.plotWidget.axes.set_ylabel('RA Error', color='white')
        self.plotWidget.axes.set_title('RA Error referenced to 0 over Modeling\n ', color='white')
        self.plotWidget.axes.axis([0, len(self.data['Index']), -self.scaleRA, self.scaleRA])
        raErrorDeviation = numpy.asarray(self.data['RaError'])
        self.plotWidget.axes.plot(self.data['Index'], raErrorDeviation - raErrorDeviation[0], color='black')                 # Basic Data
        colors = numpy.asarray(['blue' if x > 180 else 'green' for x in self.data['Azimuth']])
        self.plotWidget.axes.scatter(self.data['Index'], raErrorDeviation - raErrorDeviation[0], c=colors, s=50)
        self.plotWidget.draw()

    def showDecErrorAltitude(self):
        if len(self.data) > 0:
            self.data = self.analyse.prepareData(self.data, self.scaleRA, self.scaleDEC)
        else:
            return
        self.setFigure()
        self.plotWidget.axes.set_xlabel('Altitude', color='white')
        self.plotWidget.axes.set_ylabel('DEC Error (arcsec)', color='white')
        self.plotWidget.axes.set_title('DEC Error over Altitude\n ', color='white')
        self.plotWidget.axes.set_xlim(0, 90)
        self.plotWidget.axes.set_ylim(-self.scaleDEC, self.scaleDEC)
        self.plotWidget.axes.plot(self.data['Altitude'], self.data['DecError'], color='black')
        colors = numpy.asarray(['blue' if x > 180 else 'green' for x in self.data['Azimuth']])
        self.plotWidget.axes.scatter(self.data['Altitude'], self.data['DecError'], c=colors, s=50)
        self.plotWidget.draw()

    def showRaErrorAltitude(self):
        if len(self.data) > 0:
            self.data = self.analyse.prepareData(self.data, self.scaleRA, self.scaleDEC)
        else:
            return
        self.setFigure()
        self.plotWidget.axes.set_xlabel('Altitude', color='white')
        self.plotWidget.axes.set_ylabel('RA Error (arcsec)', color='white')
        self.plotWidget.axes.set_title('RA Error over Altitude\n ', color='white')
        self.plotWidget.axes.set_xlim(0, 90)
        self.plotWidget.axes.set_ylim(-self.scaleRA, self.scaleRA)
        self.plotWidget.axes.plot(self.data['Altitude'], self.data['RaError'], color='black')
        colors = numpy.asarray(['blue' if x > 180 else 'green' for x in self.data['Azimuth']])
        self.plotWidget.axes.scatter(self.data['Altitude'], self.data['RaError'], c=colors, s=50)
        self.plotWidget.draw()

    def showDecErrorAzimuth(self):
        if len(self.data) > 0:
            self.data = self.analyse.prepareData(self.data, self.scaleRA, self.scaleDEC)
        else:
            return
        self.setFigure()
        self.plotWidget.axes.set_xlabel('Altitude', color='white')
        self.plotWidget.axes.set_ylabel('DEC Error (arcsec)', color='white')
        self.plotWidget.axes.set_title('DEC Error over Azimuth\n ', color='white')
        self.plotWidget.axes.set_xlim(0, 360)
        self.plotWidget.axes.set_ylim(-self.scaleDEC, self.scaleDEC)
        self.plotWidget.axes.plot(self.data['Azimuth'], self.data['DecError'], color='black')
        colors = numpy.asarray(['blue' if x > 180 else 'green' for x in self.data['Azimuth']])
        self.plotWidget.axes.scatter(self.data['Azimuth'], self.data['DecError'], c=colors, s=50)
        self.plotWidget.draw()

    def showRaErrorAzimuth(self):
        if len(self.data) > 0:
            self.data = self.analyse.prepareData(self.data, self.scaleRA, self.scaleDEC)
        else:
            return
        self.setFigure()
        self.plotWidget.axes.set_xlabel('Altitude', color='white')
        self.plotWidget.axes.set_ylabel('RA Error (arcsec)', color='white')
        self.plotWidget.axes.set_title('RA Error over Azimuth\n ', color='white')
        self.plotWidget.axes.set_xlim(0, 360)
        self.plotWidget.axes.set_ylim(-self.scaleRA, self.scaleRA)
        self.plotWidget.axes.plot(self.data['Azimuth'], self.data['RaError'], color='black')
        colors = numpy.asarray(['blue' if x > 180 else 'green' for x in self.data['Azimuth']])
        self.plotWidget.axes.scatter(self.data['Azimuth'], self.data['RaError'], c=colors, s=50)
        self.plotWidget.draw()

    def showModelPointPolar(self):
        self.setFigure('polar')
        self.plotWidget.axes.set_theta_zero_location('N')
        self.plotWidget.axes.set_theta_direction(-1)
        self.plotWidget.axes.set_yticks(range(0, 90, 10))
        yLabel = ['', '80', '', '60', '', '40', '', '20', '', '0']
        self.plotWidget.axes.set_yticklabels(yLabel, color='white')
        self.plotWidget.axes.set_title('Model Points\n ', color='white')
        azimuth = numpy.asarray(self.data['Azimuth'])
        altitude = numpy.asarray(self.data['Altitude'])
        colors = numpy.asarray(['blue' if x > 180 else 'green' for x in self.data['Azimuth']])
        self.plotWidget.axes.plot(azimuth / 180.0 * 3.141593, 90 - altitude, color='black')
        self.plotWidget.axes.scatter(azimuth / 180.0 * 3.141593, 90 - altitude, c=colors, s=50)
        self.plotWidget.axes.set_rmax(90)
        self.plotWidget.axes.set_rmin(0)
        self.plotWidget.draw()

    def showModelPointErrorPolar(self):
        self.setFigure('polar')
        self.plotWidget.axes.set_theta_zero_location('N')
        self.plotWidget.axes.set_theta_direction(-1)
        self.plotWidget.axes.set_yticks(range(0, 90, 10))
        yLabel = ['', '80', '', '60', '', '40', '', '20', '', '0']
        self.plotWidget.axes.set_yticklabels(yLabel, color='white')
        self.plotWidget.axes.set_title('Model Points Error\n ', color='white')
        azimuth = numpy.asarray(self.data['Azimuth'])
        altitude = numpy.asarray(self.data['Altitude'])
        self.plotWidget.axes.plot(azimuth / 180.0 * 3.141593, 90 - altitude, color='black')
        cm = plt.cm.get_cmap('RdYlGn_r')
        colors = numpy.asarray(self.data['ModelError'])
        scaleError = int(max(colors) / 4 + 1) * 4
        area = colors * 100 / self.scaleError + 20
        theta = azimuth / 180.0 * 3.141593
        r = 90 - altitude
        scatter = self.plotWidget.axes.scatter(theta, r, c=colors, vmin=0, vmax=scaleError, s=area, cmap=cm)
        scatter.set_alpha(0.75)
        colorbar = self.plotWidget.fig.colorbar(scatter)
        colorbar.set_label('Error [arcsec]', color='white')
        plt.setp(plt.getp(colorbar.ax.axes, 'yticklabels'), color='white')
        self.plotWidget.axes.set_rmax(90)
        self.plotWidget.axes.set_rmin(0)
        self.plotWidget.draw()


text:
.modal-xdialog .btn {
    min-width: 75px;
}

.modal-xdialog .modal-dialog {
    width: 500px;
}

.modal-xdialog.in .modal-dialog {
    opacity: 0;
    transform: none;
}

.modal-xdialog.fade .modal-dialog {
    opacity: 1;
    transform: none;
    transition: all 0s ease-out 0s;
}

.modal-xdialog .modal-header .close {
    margin-top: 1px;
}

.modal-xdialog .modal-content {
    background-color: #eeeeee;
}

.modal-xdialog .modal-header {
    background-color: #428BCA;
    border: 1px solid #EEEEEE;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.4);
    color: #FFFFFF;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    padding: 10px;
}

.modal-xdialog .modal-header-danger {
    background-color: #D9534F;
}

.modal-xdialog .modal-header-warning {
    background-color: #F0AD4E;
}

.modal-xdialog .modal-header-info {
    background-color: #5BC0DE;
}

.modal-xdialog .modal-header-success {
    background-color: #5CB85C;
}

.modal-xdialog .modal-header-invert {
    background-color: #999999;
}

.modal-xdialog .modal-footer {
    margin-top: 0;
    border: none;
    padding: 0 20px 15px;
}

.modal-xdialog td#col-text {
    padding-left:10px;
}

.modal.modal-message-box {
    overflow-y: auto;
}

.modal-message-box > .modal-dialog {
    margin-top: 10%;
}

redpajama_set_name: RedPajamaGithub


text:
package io.github.jbalancer.proxy.dashboard;

import io.github.jbalancer.Balancer;
import io.github.jbalancer.JBalancer;
import io.github.jbalancer.node.Node;
import io.github.jbalancer.node.discoverer.YamlNodeDiscoverer;
import io.github.jbalancer.proxy.YamlNodesStorage;
import io.github.jbalancer.strategy.RoundRobinStrategy;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Component
public class DashboardController {

    private final JBalancer jBalancer;
    private final YamlNodesStorage yamlNodesStorage;

    @Autowired
    public DashboardController(JBalancer jBalancer, YamlNodesStorage yamlNodesStorage) {
        this.jBalancer = jBalancer;
        this.yamlNodesStorage = yamlNodesStorage;
    }

    public List<ANode> getAllNodes() {

        final List<Balancer> balancers = jBalancer.getBalancers();

        final List<ANode> result = new ArrayList<>();
        balancers.forEach(b -> result.addAll(b.getAll().stream()
                .map(bn -> (Node) bn)
                .map(n -> create(b.getId(), n))
                .collect(Collectors.toList())));
        return result;
    }

    public List<ABalancer> getAllBalancers() {

        final List<Balancer> balancers = jBalancer.getBalancers();

        final List<ABalancer> result = new ArrayList<>();
        balancers.forEach(b -> result.add(new ABalancer(b.getId(), StringUtils.EMPTY)));
        return result;
    }

    public ABalancer save(ABalancer aBalancer) {

        final String balancerId = aBalancer.getId();

        yamlNodesStorage.save(aBalancer.getId(), aBalancer.getYamlNodes());
        final Balancer balancer = jBalancer.getBalancer(balancerId);
        if (null == balancer) {
            jBalancer.create(balancerId, new RoundRobinStrategy(), new YamlNodeDiscoverer(s -> yamlNodesStorage.getYamlNodes(balancerId)));
        }
        return aBalancer;
    }

    public ABalancer getBalancer(String balancerId) {

        final String yamlnodes = yamlNodesStorage.getYamlNodes(balancerId);
        return new ABalancer(balancerId, yamlnodes);
    }

    private ANode create(String balancerId, Node node) {
        return new ANode(
                balancerId,
                node.getLabels(),
                null == node.getConnection() ? "" : node.getConnection().toString(),
                null == node.getStatus() ? "" : node.getStatus().toString(),
                node.isAlive(),
                node.isActive(),
                node.isEnabled(),
                node.getCheckStatus()
        );
    }
}


text:
export const environment = {
  production: true,
  groupsApi: 'https://shufflizer.herokuapp.com/api/groups',
  usersApi: 'https://shufflizer.herokuapp.com/api/users',
  authRedirect: 'https://shufflizer.herokuapp.com/'
};


text:
<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Sahabat OLX</title>

    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <link href='https://fonts.googleapis.com/css?family=Roboto:400,700,300,100' rel='stylesheet' type='text/css'>
    <link href="css/custom.css" rel="stylesheet">

PASAR

          Mohon dibaca terlebih dahulu

Barang yang dijual pada acara ini adalah barang yang masih layak untuk diperjualbelikan, sudah diiklankan di OLX danharus sesuai dengan syarat dan ketentuan berjualan OLX.

Kami berhak menolak atau mengeluarkan peserta yang tidak mengikuti syarat dan ketentuan berjualan di OLX dan atau mengganggu kelangsungan acara.

Dengan melakukan pendaftaran, Anda sepakat untuk meluangkan waktu untuk hadir di hari yang Anda pilih pada saat pendaftaran, mulai jam 12 siang hingga 8 malam.

OLX hanya menyediakan slot parkir mobil untuk Anda berjualan, silakan mempersiapkan perlengkapan lain yang Anda butuhkan.

Silakan menjaga keamanan barang yang Anda jual, OLX tidak bertanggung jawab atas kehilangan atau kerugian yang Anda alami selama acara.

 BACK


text:
(function () {
  'use strict';

  angular
    .module('dopplerRelay')
    .service('utils', utils);

  utils.$inject = [
    '$http',
    '$window',
    '$q',
    'RELAY_CONFIG',
    '$rootScope'
  ];

  var domainsData = [
    { companyName: 'Gire', logoName: 'gire-logo-grey', domainRegex: /^mailing.gire.com$/, companyLink: "http://giresoluciones.com.ar" },
    { companyName: 'Test', logoName: 'american-card', domainRegex: /\.test\.com$/, companyLink: "http://test.com.ar" }];
  var relayDomainData =  { companyName: "Doppler Relay", default: true };

  function utils($http, $window, $q, RELAY_CONFIG, $rootScope) {
    var hostName = $window.location.hostname;
    var domainData = domainsData.find(function(x) {
        return x.domainRegex.test(hostName);
    });
    if(!domainData){
      domainData = relayDomainData;
    }
    $rootScope.companyName = domainData.companyName;

    var utilsService = {
      analizePasswordComplexity: analizePasswordComplexity,
      setServerValidationToField: setServerValidationToField,
      resetForm: resetForm,
      replaceAllCharsExceptLast4: replaceAllCharsExceptLast4,
      validateCreditCard : validateCreditCard,
      removeDuplicates: removeDuplicates,
      getPreferredLanguage: getPreferredLanguage,
      setPreferredLanguage: setPreferredLanguage,
      domainData: domainData
    };

    return utilsService;

    function analizePasswordComplexity(password) {
      var SAME = /^(.)\1+$/;
      if (password && password.length >= 8 && !SAME.test(password)) {

        var LOWER = /[a-z]/,
          UPPER = /[A-Z]/,
          DIGIT = /[0-9]/,
          SPECIAL = /\W/;

        var lower = LOWER.test(password),
            upper = UPPER.test(password),
            digit = DIGIT.test(password),
            special = SPECIAL.test(password);

        if (lower && upper && digit || special) {
          return {
            strength: 'strong',
            result: true,
            position: 2
          };
        }

        if (lower && upper || lower && digit || upper && digit) {
          return {
            strength: 'good',
            result: true,
            position: 1
          };
        }

      }

      return {
        strength: 'weak',
        result: false,
        position: 2
      };
    }

    function setServerValidationToField(scope, formField, errorName) {
      // It is a quick and dirty way to set a validation error that is removed when
      // a change is detected.
      formField.$setValidity(errorName, false);
      var deregister = scope.$watch(function () { return formField.$modelValue; }, function (newVal, oldVal) {
        if (newVal != oldVal) {
          formField.$setValidity(errorName, null);
          deregister();
        }
      });
    }

    function resetForm(vm, form, defaultValues) {
      var undefined = {}["undefined"]; // It is not a good practice to use the `undefined` because it is not a reserved word
      defaultValues = defaultValues || {}; // defaultValues is to allow to set default model values in place of null
      for (var name in form) {
        if (name.indexOf('$') !== 0) {
          var control = form[name];
          control.$setViewValue(undefined);
          vm[control.$name] = defaultValues[control.$name] || null;
        }
      }
      form.$setPristine();
      form.$setUntouched();
    }

    function replaceAllCharsExceptLast4(str) {
      var length = str.toString().length - 4;
      if (length < 4) {
        return str.replace(/\S/gi, '*');;
      }
      return str.replace(/\S/gi,
        function myFunction(x,i){
          if (i < length) {
            return "*";
          }
          return x;
        });
    }

    //This was taken from: https://gist.github.com/DiegoSalazar/4075533
    function validateCreditCard(value) {
      // accept only digits, dashes or spaces
    	if (/[^0-9-\s]+/.test(value)) return false;

    	// The Luhn Algorithm.
    	var nCheck = 0, nDigit = 0, bEven = false;
    	value = value.replace(/\D/g, "");

    	for (var n = value.length - 1; n >= 0; n--) {
    		var cDigit = value.charAt(n),
    			  nDigit = parseInt(cDigit, 10);

    		if (bEven) {
    			if ((nDigit *= 2) > 9) nDigit -= 9;
    		}

    		nCheck += nDigit;
    		bEven = !bEven;
    	}

    	return (nCheck % 10) == 0;
    }

    function removeDuplicates(arr){
        var o = {};
        for(var e = 0; e < arr.length; e++) {
          o[arr[e]] = true;
        }
        return Object.keys(o);
      }

    function getPreferredLanguage(){
      return $window.localStorage.getItem('lang');
    }

    function setPreferredLanguage(key){
      $window.localStorage.setItem('lang', key);
    }
  }
})();


text:
<?php

namespace Cart;

interface Arrayable
{
    /**
     * Get the instance as an array.
     *
     * @return array
     */
    public function toArray();
}


text: <input type="checkbox" name="ids[]" value="<?php echo $terms->getPrimaryKey() ?>" class="sf_admin_batch_checkbox" />


text:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="description" content="CMU Asian Students Association" />
    <meta name="author" content="" />
    <link rel="icon" href="img/favicon.png" />

    <title>CMU ASA Advocacy</title>

    <meta property="og:title" content="CMU Asian Students Association" />
    <meta property="og:type" content="website" />
    <meta property="og:description"
        content="Carnegie Mellon University Asian Students Association, better known as CMU ASA, the largest cultural student organization on campus." />
    <meta property="og:image" content="https://i.ibb.co/3WBPLnq/asa.jpg" />

    <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" />

    <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css" />
    <link href="https://fonts.googleapis.com/css?family=Kaushan+Script" rel="stylesheet" type="text/css" />
    <link href="https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic,700italic" rel="stylesheet"
        type="text/css" />
    <link href="https://fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700" rel="stylesheet" type="text/css" />

    <link href="css/styles.css" rel="stylesheet" />

            cmu asa
            <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse"
                data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false"
                aria-label="Toggle navigation">
                Menu

            </button>

ASA Lovin'

About

Board

Newsletters

Mailing List

Advocacy

:: Advocacy ::

Past Events

Food for Thought

Presented by Jeffrey Chiu on 10/21/20

This week we talked about the importance of food in Asian culture. We explored the idea of impact vs intent by looking at cases where white chefs running Asian style.. Read More

This week we talked about the importance of food in Asian culture. We explored the idea of impact vs intent by looking at cases where white chefs running Asian style.. Read More

                            Recap

                            Resources

Immigration Reform and ICE

Presented by Jeffrey Chiu on 10/17/20

In this workshop, we discussed the history of immigration laws in the United States surrounding the Asian American immigrant. We talked about the importance of the.. Read More

In this workshop, we discussed the history of immigration laws in the United States surrounding the Asian American immigrant. We talked about the importance of the.. Read More

                            Recap

                            Resources

            &copy 2020 CMU ASA


text:
import decimal
import ipaddr
from django.contrib.auth import models as auth_models
from django.core import exceptions
from django.db.models import *
from nodehub import forms
from nodehub import utils

class IPAddressField(Field):
    __metaclass__ = SubfieldBase
    description = 'An IP address stored as a decimal'

    def _format(self, value):
        try:
            return unicode(self.to_python(value)) or ''
        except ValueError:
            return ''

    def clean(self, value, *args, **kwargs):
        value = super(IPAddressField, self).clean(value, *args, **kwargs)
        try:
            self.to_python(value)
        except ValueError:
            raise exceptions.ValidationError('Enter a valid IP address.')
        return value

    def to_python(self, value):
        if not value:
            return None

        if isinstance(value, (ipaddr.IPv4Network, ipaddr.IPv6Network)):
            return value.network
        elif isinstance(value, (ipaddr.IPv4Address, ipaddr.IPv6Address)):
            return value
        elif isinstance(value, decimal.Decimal):
            value = int(value)

        return ipaddr.IPAddress(value)

    def get_internal_type(self):
        return 'DecimalField'

    def get_db_prep_value(self, value, connection, prepared=False):
        return connection.ops.value_to_db_decimal(
            decimal.Decimal(int(self.get_prep_value(value))),
            39, 0)

    def get_prep_value(self, value):
        return self.to_python(value)

    def formfield(self, **kwargs):
        defaults = {'form_class': forms.IPAddressField}
        defaults.update(kwargs)
        return super(IPAddressField, self).formfield(**defaults)

class MACAddressField(fields.CharField):

    def __init__(self, *args, **kwargs):
        kwargs['max_length'] = 12
        super(MACAddressField, self).__init__(*args, **kwargs)

    def formfield(self, **kwargs):
        defaults = {'form_class': forms.MACAddressField}
        defaults.update(kwargs)
        return super(MACAddressField, self).formfield(**defaults)

class NameField(fields.CharField):

    def __init__(self, hostname=True, *args, **kwargs):
        kwargs['max_length'] = 255
        self.hostname = hostname
        super(NameField, self).__init__(*args, **kwargs)

    def clean(self, value, *args, **kwargs):
        value = super(NameField, self).clean(value, *args, **kwargs)
        if value:
            utils.validate_dns_name(value, self.hostname)
        return value

class TimestampModel(Model):
    created = DateTimeField(auto_now_add=True)
    updated = DateTimeField(auto_now=True)

    class Meta:
        abstract = True

class BaseModel(TimestampModel):

    class Meta:
        abstract = True

class ModifierModel(BaseModel):
    MOD_CHOICES = (
        (1, 'set'),
        (2, 'unset'),
    )
    name = CharField(max_length=255)
    operator = IntegerField(choices=MOD_CHOICES)
    value = TextField(blank=True)
    priority = IntegerField(default=0)

    def __unicode__(self):
        return u'%s %s %s' % (self.name, self.operator, self.value)

    class Meta:
        abstract = True
        ordering = ['name', 'priority']


text:
#include "test_common.h"
#include "cl_device.h"
#include "cl_context.h"
#include "cl_kernel.h"
#include <unistd.h>
#include <libgen.h>

using namespace XCam;

struct TestFileHandle {
    FILE *fp;
    TestFileHandle ()
        : fp (NULL)
    {}
    ~TestFileHandle ()
    {
        if (fp)
            fclose (fp);
    }
};

static XCamReturn
get_kernel_name(char *input_file, char **kernel_name)
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;

    char *base_name = basename (input_file);
    size_t kernel_name_length = strlen (base_name) - 3;

    *kernel_name = (char *) xcam_malloc0 (sizeof (char) * kernel_name_length);
    XCAM_ASSERT(*kernel_name);

    strncpy (*kernel_name, base_name, kernel_name_length);

    return ret;
}

static XCamReturn
get_source_sizes (TestFileHandle &file, size_t *source_sizes)
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;

    if (fseek (file.fp, 0 , SEEK_END) != 0)
        goto read_error;

    if ((*source_sizes = ftell (file.fp)) <= 0)
        goto read_error;

    rewind(file.fp);

    return ret;

read_error:
    XCAM_LOG_ERROR ("get source sizes failed");
    return XCAM_RETURN_ERROR_FILE;
}

static XCamReturn
read_source (TestFileHandle &file, char *source, size_t source_sizes)
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;

    if (fread (source, sizeof (char), source_sizes, file.fp) != source_sizes) {
        XCAM_LOG_ERROR ("read source failed, size doesn't match");
        ret = XCAM_RETURN_ERROR_FILE;
    }

    return ret;
}

static XCamReturn
write_binary (TestFileHandle &file, uint8_t *binaries, const size_t binary_sizes)
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;

    if (fwrite (binaries, sizeof (uint8_t), binary_sizes, file.fp) != binary_sizes) {
        XCAM_LOG_ERROR ("write binary failed, size doesn't match");
        ret = XCAM_RETURN_ERROR_FILE;
    }

    return ret;
}

static void
print_help (const char *bin_name)
{
    printf ("Usage: %s -i <source-file> -o <binary-file>\n"
            "\t -i input-file     specify source file path\n"
            "\t -o output-file    specify binary file path\n"
            "\t -h                help\n"
            , bin_name);
}

int main (int argc, char *argv[])
{
    int opt = 0;
    const char *bin_name = argv[0];
    char *source_file = NULL, *binary_file = NULL;
    size_t source_sizes = 0;
    size_t binary_sizes = 0;
    char *kernel_name = NULL;
    char *kernel_body = NULL;
    uint8_t *program_binaries = NULL;
    TestFileHandle source_fp, binary_fp;
    XCamReturn ret = XCAM_RETURN_NO_ERROR;

    while ((opt = getopt (argc, argv, "i:o:h")) != -1) {
        switch (opt) {
        case 'i':
            source_file = optarg;
            break;
        case 'o':
            binary_file = optarg;
            break;
        case 'h':
            print_help (bin_name);
            return 0;

        default:
            print_help (bin_name);
            return -1;
        }
    }

    if (!source_file || !binary_file) {
        print_help (bin_name);
        return -1;
    }

    source_fp.fp = fopen (source_file, "r");
    binary_fp.fp = fopen (binary_file, "wb");
    if (!source_fp.fp || !binary_fp.fp) {
        XCAM_LOG_ERROR ("open source/binary file failed");
        return -1;
    }

    ret = get_source_sizes (source_fp, &source_sizes);
    CHECK (ret, "get source sizes from %s failed", source_file);

    kernel_body = (char *) xcam_malloc0 (sizeof (char) * source_sizes);
    XCAM_ASSERT(kernel_body);

    ret = read_source (source_fp, kernel_body, source_sizes);
    CHECK (ret, "read source from %s failed", source_file);

    SmartPtr<CLContext> context;
    context = CLDevice::instance ()->get_context ();

    ret = get_kernel_name (source_file, &kernel_name);
    CHECK (ret, "get kernel name failed");

    SmartPtr<CLKernel> kernel = new CLKernel (context, kernel_name);
    xcam_free (kernel_name);

    kernel->load_from_source (kernel_body, strlen (kernel_body), &program_binaries, &binary_sizes);

    ret = write_binary (binary_fp, program_binaries, binary_sizes);
    CHECK (ret, "write binary to %s failed", binary_file);

    xcam_free (kernel_body);
    xcam_free (program_binaries);
    return 0;
}


text:
<?php

namespace Common\Form;

use Backend\Core\Engine\Header as BackendHeader;
use Common\Core\Header\Priority;
use Frontend\Core\Header\Header as FrontendHeader;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class DatePickerType extends DateType
{
    /**
     * @var BackendHeader|FrontendHeader
     */
    private $header;

    public function __construct(ContainerInterface $container)
    {
        $this->header = $container->get('header');
    }

    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        parent::buildForm($builder, $options);

        if ($this->header instanceof BackendHeader) {
            $this->header->addJS('/js/vendors/bootstrap-datepicker.min.js', null, false, true, true, Priority::core());
            $this->header->addCSS('/css/vendors/bootstrap-datepicker3.standalone.min.css', null, true, false, true, Priority::core());

            return;
        }

        $this->header->addJS('/js/vendors/bootstrap-datepicker.min.js', false, true, Priority::core());
        $this->header->addCSS('/css/vendors/bootstrap-datepicker3.standalone.min.css', false, true, Priority::core());
    }

    public function configureOptions(OptionsResolver $resolver): void
    {
        parent::configureOptions($resolver);
        $resolver->setDefault('widget', 'single_text');
        $resolver->setDefault('html5', false);
        $resolver->setDefault('format', 'dd/MM/yyyy');
        $resolver->setDefault(
            'attr',
            [
                'data-role' => 'fork-datepicker',
            ]
        );
    }
}