This file contains hidden or 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
NameVirtualHost *:80 | |
<VirtualHost *:80> | |
ServerAdmin [email protected] | |
DocumentRoot "D:/Projects/PHP/silex-test/web" | |
ServerName silex-test.loc | |
ServerAlias www.silex-test.loc | |
ErrorLog "logs/dummy-host.example.com-error.log" | |
CustomLog "logs/dummy-host.example.com-access.log" common | |
</VirtualHost> |
This file contains hidden or 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
// under Google Chrome 36 | |
Object.prototype.toString.call([]) | |
// "[object Array]" | |
Object.prototype.toString.call(function(){}) | |
// "[object Function]" | |
Object.prototype.toString.call({}) | |
// "[object Object]" | |
Object.prototype.toString.call(null) | |
// "[object Null]" |
This file contains hidden or 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
# List users by average and maximum session length. | |
SELECT person, max(client.runtime_ms), avg(client.runtime_ms) | |
FROM item_occurrence | |
GROUP BY 1 | |
ORDER BY 2 DESC | |
# List active date ranges for each deploy. | |
SELECT client.javascript.code_version, min(timestamp), max(timestamp) | |
FROM item_occurrence | |
GROUP BY 1 |
This file contains hidden or 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 asyncToReact(fn) { | |
class PromiseComponent extends React.Component { | |
state = { waiting: true, result: null }; | |
componentDidMount() { | |
fn(...this.props.args).then(result => this.setState({ waiting: false, result })); | |
} | |
componentDidUpdate() { | |
fn(...this.props.args).then(result => this.setState({ waiting: false, result })); | |
} | |
shouldComponentUpdate(newProps) { |
This file contains hidden or 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 asyncThread(fn, ...args) { | |
if (!window.Worker) throw Promise.reject( | |
new ReferenceError(`WebWorkers aren't available.`) | |
); | |
const fnWorker = ` | |
self.onmessage = function(message) { | |
(${fn.toString()}) | |
.apply(null, message.data) | |
.then(result => self.postMessage(result)); |
This file contains hidden or 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 vkeys = { | |
0: 'unk', | |
1: 'mouse1', | |
2: 'mouse2', | |
3: 'break', | |
4: 'mouse3', | |
5: 'mouse4', | |
6: 'mouse5', | |
8: 'backspace', | |
9: 'tab', |
This file contains hidden or 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 regEx = /<a.*href=\"(https?\:\/\/gist\.github\.com\/\w*\/\w*)".*>.*<\/a>/gi; | |
const html = 'hola <a href="https://gist.github.com/sergiodxa/478eb21b6eb27d77e44bdd7d9732a46f" target="_blank" rel="nofollow">https://gist.github.com/sergiodxa/478eb21b6eb27d77e44bdd7d9732a46f</a> mundo'; | |
const finalHTML = html.replace(regEx, '<script src="$1.js"></script><noscript>Github Gist <a href="$1" target="_blank" rel="nofollow">$1</a></noscript>'); | |
document.write(finalHTML); | |
// result | |
// hola <script src="https://gist.github.com/sergiodxa/478eb21b6eb27d77e44bdd7d9732a46f.js"></script><noscript>Github Gist <a href="https://gist.github.com/sergiodxa/478eb21b6eb27d77e44bdd7d9732a46f" target="_blank" rel="nofollow">https://gist.github.com/sergiodxa/478eb21b6eb27d77e44bdd7d9732a46f</a></noscript> mundo |
This file contains hidden or 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 messages = { | |
year: { singular: 'year', plural: 'years', denominator: 365, inSeconds: 31536000 }, | |
day: { singular: 'day', plural: 'days', denominator: 24, inSeconds: 86400 }, | |
hour: { singular: 'hour', plural: 'hours', denominator: 60, inSeconds: 3600 }, | |
minute: { singular: 'minute', plural: 'minutes', denominator: 60, inSeconds: 60 }, | |
second: { singular: 'second', plural: 'seconds', inSeconds: 1 } | |
} | |
function pluralize(value, unit) { | |
if (value === 1) return messages[unit].singular; |
This file contains hidden or 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 FeatureFlags = React.createContext(null); | |
export function FeatureProvider({ features = null, children }) { | |
if (features === null || typeof features !== "object") { | |
throw new TypeError("The features prop must be an object or an array."); | |
} | |
return ( | |
<FeatureFlags.Provider value={features}>{children}</FeatureFlags.Provider> |
This file contains hidden or 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 { randomBytes } from 'crypto'; | |
import * as React from 'react'; | |
import { Request, Session } from 'remix'; | |
import { parseBody, parseParams } from './parse-body'; | |
/** | |
* An error that is thrown when a CSRF token is missing or invalid. | |
* @example | |
* throw new InvalidAuthenticityToken("Can't verify CSRF token authenticity."); | |
* @example |
OlderNewer