Skip to content

Instantly share code, notes, and snippets.

View rezen's full-sized avatar

Andres Hermosilla rezen

View GitHub Profile
@dhrrgn
dhrrgn / paths.php
Last active December 20, 2015 09:08
A few handy functions for dealing with paths in PHP in a cross-platform environment.
<?php
if ( ! defined('IS_WIN')) {
define('IS_WIN', (DIRECTORY_SEPARATOR === '\\'));
}
/**
* Normalizes and joins path segments in accordance with the current OS standard.
*
* Usage:
*
@bvaughn
bvaughn / gist:012fb525e6c819fdc9bf
Last active May 23, 2016 15:01
Debugging Angular bindings

This afternoon I encountered a race condition in an Angular app I'm working on. Essentially my controller was pushing some values to an Array on its scope and something (I wasn't sure what) was asynchronously overriding the Array's contents. The Array was being used by a custom directive- written by someone else- as well as an ngModel and it wasn't clear who was making the change.

I ended up trying something I had not done before and it worked well enough that I thought I'd post it here in case it helped anyone else.

First I enabled The "Async" option in Chrome's "Sources > Call Stack" panel.

Next I set a breakpoint in my controller where I was modifying the Array. When I hit that breakpoint, I ran the following code in my console:

Object.observe(this.theArray, function(changes) {
@rjz
rjz / completely-distributed-web-futuretalk.md
Created March 15, 2016 02:15
The completely distributed web - Kyle Drake

The Completely Distributed Web

Presenter: Kyle Drake (@kyledrake) - founder, neocities.org


Cryptography - check against government power

  • Conversations lately are talking about "crypto wars 2.0" (Schneier, et. al)
  • Mid '90s, crypto was weak and bad - maybe deliberate to facilitate brute-force hacking by state-sponsored players
@darkyen
darkyen / Id3NodeReader.js
Created April 24, 2012 17:23
A simple ID3v2.3.0 Tag Reader written for node.js
var fs = require('fs');
var Buffer = require('buffer').Buffer;
var id3Reader = new (function(){
// Credits to esailja //
var self = this;
function id3Size( buffer ) {
var integer = ( ( buffer[0] & 0x7F ) << 21 ) |
( ( buffer[1] & 0x7F ) << 14 ) |
( ( buffer[2] & 0x7F ) << 7 ) |
@sunggun-yu
sunggun-yu / gist:4416430
Created December 31, 2012 00:42
Install NMON - CentOS 64bit
# Get Root
sudo su
# Download NMON archive
cd /tmp
wget http://nmon.sourceforge.net/docs/MPG_nmon_for_Linux_14a_binaries.zip
# Install unzip if you don't have
yum install unzip
@batandwa
batandwa / dump.py
Created May 5, 2014 08:51
A configurable python script that wraps around mysqldump with some additional configuration.
#!/usr/bin/python
# Run with:
# python hello.py cameron
# python hello.py
# import modules used here -- sys is a very standard one
import sys
import subprocess
@wader
wader / disable_sendfile_linux.go
Last active September 13, 2018 04:47
go http VirtualBox vboxfs sendfile bug workaround
// VirtualBox vboxsf sendfile bug workaround
// use seccomp to make sendfile return ENOTSUP which makes go http fallback to io.Copy
//
// if running in docker make sure to give SYS_ADMIN capabilities to container:
// docker create --cap-add=SYS_ADMIN
// docker-compose:
// cap_add:
// - SYS_ADMIN
//
// Licensed as public domain
@radu-gheorghe
radu-gheorghe / log_backup.bash
Created July 26, 2012 08:31
Optimize&Backup Elasticsearch index. And restore.
#!/usr/bin/env bash
###############FUNCTIONS############
function prepare {
#optimize the index
echo -n "Optimizing index $INDEX_NAME..."
curl -XPOST "$ADDRESS/$INDEX_NAME/_optimize" 2>/dev/null| grep 'failed":0' >/dev/null
if [ $? -eq 0 ]; then
echo "done"
@jtai
jtai / parse-tcpdump-udp-port-53.php
Last active January 16, 2019 16:06
Quick and dirty script to parse output of /usr/sbin/tcpdump -vvv -s 0 -l port 53
<?php
// quick and dirty argument parsing
foreach ($argv as $arg) {
if ($arg == '-f') {
define('FOLLOW', true);
}
if ($arg == '-h') {
define('HISTOGRAM', true);
}
@NateWr
NateWr / imager-for-wp.php
Created March 12, 2014 01:07
Integrate Imager.js with WordPress
<?php
/**
* Integrate Imager.js with WordPress
*
* Imager.js is BBC's solution for serving responsive and retina images, without
* the double payload issues that affect other solutions. For more information:
*
* https://github.com/BBC-News/Imager.js/
*
* This collection of functions modifies the output of WordPress's