Skip to content

Instantly share code, notes, and snippets.

View Sannis's full-sized avatar
🎯
Focusing

Oleg Efimov Sannis

🎯
Focusing
View GitHub Profile
@sirmax
sirmax / fix-wifi.sh
Last active December 11, 2015 15:28
#! /usr/bin/env bash
function nEnabled {
system_profiler -detailLevel mini SPAirPortDataType | grep -e 'Supported PHY Modes: .*n'
}
until nEnabled && sleep 2 && nEnabled;
do
echo 'resetting airport'
networksetup -setairportpower en1 off; networksetup -setairportpower en1 on
@agnoster
agnoster / README.md
Last active April 6, 2024 22:35
My ZSH Theme

agnoster.zsh-theme

A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

For Mac users, I highly recommend iTerm 2 + Solarized Dark

@oleics
oleics / moduleofmodule.js
Created June 28, 2012 15:03
module of module
var foo = require('./foo')
, barOfFoo = moduleOfModule('./bar', './foo')
function moduleOfModule(module, ofModule) {
var c = require.cache[require.resolve(ofModule)]
, f = require.resolve(module, c)
, r
c.children.some(function(c) {
if(c.filename === f) {
r = c.exports
@mikeal
mikeal / gist:2504336
Created April 27, 2012 00:11
Date parsing JSON
JSON._dateReviver = function (k,v) {
if (v.length !== 24 || typeof v !== 'string') return v
try {return new Date(v)}
catch(e) {return v}
}
JSON.parseWithDates = function (obj) {
return JSON.parse(obj, JSON._dateReviver);
}
@slevithan
slevithan / xregexp-lookbehind2.js
Created April 14, 2012 21:06
Simulating lookbehind in JavaScript (take 2)
// Simulating infinite-length leading lookbehind in JavaScript. Uses XRegExp.
// Captures within lookbehind are not included in match results. Lazy
// repetition in lookbehind may lead to unexpected results.
(function (XRegExp) {
function prepareLb(lb) {
// Allow mode modifier before lookbehind
var parts = /^((?:\(\?[\w$]+\))?)\(\?<([=!])([\s\S]*)\)$/.exec(lb);
return {
@Sannis
Sannis / screencast.sh
Created March 15, 2012 21:22 — forked from pomeo/screencast.sh
script to make screencasts on Linux
#!/bin/bash
# list of programs we depend on
progs="xdpyinfo grep head sed ffmpeg pacat parec sox"
# check for programs we depend on
result=0
for prog in $progs
do
type -p $prog > /dev/null
@DavertMik
DavertMik / gist:1936860
Created February 29, 2012 01:40
Dependency Management Concept. RFC

This is about getting rid of Dependency Injection Container and DI practices taken from Java. Good bye Java, viva la PHP!

We start with common example. Session.

<?php

class SessionStorage {

 	function __construct() 
@creationix
creationix / jsonparse.js
Created February 13, 2012 23:20
event-only version of jsonparse
// Named constants with unique integer values
var C = {};
// Tokenizer States
var START = C.START = 0x11;
var TRUE1 = C.TRUE1 = 0x21;
var TRUE2 = C.TRUE2 = 0x22;
var TRUE3 = C.TRUE3 = 0x23;
var FALSE1 = C.FALSE1 = 0x31;
var FALSE2 = C.FALSE2 = 0x32;
var FALSE3 = C.FALSE3 = 0x33;
@joekim
joekim / json-protocol.js
Created December 7, 2011 03:12
A simple carriage-return, line-feed delimited JSON protocol.
/*
A simple newline delimited JSON protocol.
Receiving Usage:
protocol = require('./json-protocol');
// parsing data
parser = protocol.StreamParser();
@torgeir
torgeir / prototypes.js
Created November 29, 2011 09:17
javascript's __proto__ and prototype explained
/**
* __proto__ and prototype
* - the __proto__ property the instance's 'parent' up the prototype chain
* - the prototype property refers what new instances of the type will have their __proto__ set to, i.e. what will be the new instance's 'parent' up the prototype chain
*/
/* Given */
function Object () {}
Object.prototype = {
__proto__: null