This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//https://github.com/mohdovais/Delhi-Elections-2015 | |
spl_autoload_register( | |
function($className) | |
{ | |
$className = str_replace("_", "\\", $className); | |
$className = ltrim($className, '\\'); | |
$fileName = ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { parse } = require("acorn"); | |
const expressionStatement = node => node.type === "ExpressionStatement"; | |
function chainedProperty(subject, chainString) { | |
const chain = Array.isArray(chainString) | |
? chainString | |
: chainString.split("."); | |
const count = chain.length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
const pureMap = new WeakMap(); | |
function makeComponent(fn, compare) { | |
return class Memo extends React.Component { | |
shouldComponentUpdate(nextProps) { | |
return compare(this.props, nextProps); | |
} | |
render() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function copyToClipboard(text){ | |
var textarea = document.createElement('textarea'); | |
textarea.value = text; | |
document.body.appendChild(textarea); | |
textarea.select(); | |
document.execCommand('copy'); | |
document.body.removeChild(textarea); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Svelte does not compare objects | |
* https://github.com/sveltejs/svelte/issues/2171 | |
* and therefore store.update notifies subscribers, even if same object is | |
* returned. Otherwise the method could be much simpler: | |
* const dispatch = action => update(state => reducer(state, action)); | |
* | |
* @param {function} reducer | |
* @param {*} initialState | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Assign nested properties from `copy` to `obj` | |
* @template O, C object and copy | |
* @param {O} obj The object to copy properties to | |
* @param {C} copy The object to copy properties from | |
* @returns {O & C} a new object | |
*/ | |
function assign(obj, copy) { | |
var draft = {}; | |
var O = Object; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { normalize } from "path"; | |
import { readFileSync } from "fs"; | |
import { isRegExp } from "util"; | |
import { parse } from "acorn"; | |
const toArray = item => Array.isArray(item) ? item : [item]; | |
// https://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript#answer-3561711 | |
const escapeRegexpStr = str => str.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"); |