Skip to content

Instantly share code, notes, and snippets.

View ZakharDay's full-sized avatar

ZakharDay ZakharDay

View GitHub Profile
@thejbsmith
thejbsmith / Rails Singleton Model
Last active April 16, 2024 00:29
Rails Singleton Model
Rails Singleton Model
Taken from:
http://stackoverflow.com/questions/399447/how-to-implement-a-singleton-model/12463209#12463209
@joepie91
joepie91 / vpn.md
Last active May 11, 2026 18:00
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

  • A Russian translation of this article can be found here, contributed by Timur Demin.
  • A Turkish translation can be found here, contributed by agyild.
  • There's also this article about VPN services, which is honestly better written (and has more cat pictures!) than my article.
@MathewReiss
MathewReiss / phone.js
Created June 4, 2015 17:09
Pokedex phone.js File
var DEBUG = true;
//var name = "name", type = "type", stage = "stage", caught = "caught";
var grass = "grass", water = "water", fire = "fire", bug = "bug",
psychic = "psychic", flying = "flying", ghost = "ghost", fighting = "fighting",
normal = "normal", poison = "poison", electric = "electric", ground = "ground",
fairy = "fairy", rock = "rock", ice = "ice", dragon = "dragon";
var Pokemon = [
{ name : "MissingNo", type : "blank", stage : 100, caught : 0, species : "Glitch Pokemon"},
@GaspardP
GaspardP / sha256.js
Created June 4, 2015 15:21
SHA-256 with Javascript and Web Crypto
// Computes the SHA-256 digest of a string with Web Crypto
// Source: https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
function sha256(str) {
// Get the string as arraybuffer.
var buffer = new TextEncoder("utf-8").encode(str)
return crypto.subtle.digest("SHA-256", buffer).then(function(hash) {
return hex(hash)
})
}
@yymm
yymm / gulpfile.coffee
Last active August 29, 2015 14:16
Gulp, browserify, reactify, coffee-reactify, notify and watchify for coffeescript
#
# Ref:
# * https://gist.github.com/vojd/a2d277bc161a2674aeaa
# * https://gist.github.com/Sigmus/9253068
#
source = require 'vinyl-source-stream'
gulp = require 'gulp'
gutil = require 'gulp-util'
browserify = require 'browserify'
@nathanstilwell
nathanstilwell / apple-devices.less
Last active October 10, 2016 16:55
iPhone Media Queries
//
// Ok look, I know this is a bad idea but I'm doing this as an experiment. I'm going to get really granular with these,
// which makes them basically unsuable. But it gives a decent overview of the diversity of iThangs.
// So chill.
//
// References:
// http://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions
// https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries#-moz-device-pixel-ratio
// http://stephen.io/mediaqueries/
//
@sebmarkbage
sebmarkbage / Enhance.js
Last active March 29, 2026 17:42
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@sebmarkbage
sebmarkbage / react_legacyfactory.md
Last active March 23, 2026 03:02
Use a factory or JSX

React Element Factories and JSX

You probably came here because your code is calling your component as a plain function call. This is now deprecated:

var MyComponent = require('MyComponent');

function render() {
 return MyComponent({ foo: 'bar' }); // WARNING
@syguer
syguer / get_access_token_from_trello.rb
Last active April 23, 2019 00:31
Get access token and secret from trello
require 'oauth'
consumer = OAuth::Consumer.new(
"CONSUMER_KEY",
"CONSUMER_SECRET",
{
site: "https://trello.com",
request_token_url: "https://trello.com/1/OAuthGetRequestToken",
authorize_url: "https://trello.com/1/OAuthAuthorizeToken",
access_token_url: "https://trello.com/1/OAuthGetAccessToken"
@sebmarkbage
sebmarkbage / ElementFactoriesAndJSX.md
Last active May 17, 2022 11:06
New React Element Factories and JSX

New React Element Factories and JSX

In React 0.12, we're making a core change to how React.createClass(...) and JSX works.

If you're using JSX in the typical way for all (and only) React components, then this transition will be seamless. Otherwise there are some minor breaking changes described below.

The Problem