Skip to content

Instantly share code, notes, and snippets.

View halaei's full-sized avatar
🎵
Code for music

Hamid Alaei Varnosfaderani halaei

🎵
Code for music
View GitHub Profile
@bdotdub
bdotdub / redis.markdown
Created November 24, 2010 22:18
Running redis using upstart on Ubuntu

Running redis using upstart on Ubuntu

I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed redis onto the box and here's how I did it and some things to look out for.

To install:

@hatak
hatak / carton-setup.sh
Created May 23, 2012 15:22
install perlbrew + cpanm + carton
#!/bin/bash
PERL_STABLE="5.16.1"
echo '%< --- installing perlbrew ---'
echo
curl -kL http://install.perlbrew.pl | bash
source ~/perl5/perlbrew/etc/bashrc
perlbrew install --notest perl-${PERL_STABLE}
<?php
declare(ticks = 1);
class TimeoutException extends Exception {};
function signal_handler($signal) {
throw new TimeoutException();
}
@JPry
JPry / curl.sh
Created December 21, 2012 01:19
Use CURL to request a domain name/path from a specific IP address. Substitute the domain for "example.com", and the IP address and path in the URL.
curl -H "Host: example.com" -I http://IP.ADD.RE.SS/path/to/file/or/folder/

Running redis using upstart on Ubuntu

I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed redis onto the box and here's how I did it and some things to look out for.

To install:

@bwbaugh
bwbaugh / classify.py
Created April 25, 2013 21:03
Detecting a Specific Watermark in a Photo with Python Get example training and testing images here: <http://bwbaugh.com/stack-overflow/16222178_watermark.tar> Stack Overflow question: <http://stackoverflow.com/questions/16222178/detecting-a-specific-watermark-in-a-photo-with-python-without-scipy>
# Copyright (C) 2013 Wesley Baugh
"""Tools for text classification.
Extracted from the [infer](https://github.com/bwbaugh/infer) library.
"""
from __future__ import division
import math
from collections import defaultdict, namedtuple, Counter
from fractions import Fraction
@killercup
killercup / pandoc.css
Created July 3, 2013 11:31
Add this to your Pandoc HTML documents using `--css pandoc.css` to make them look more awesome. (Tested with Markdown and LaTeX.)
/*
* I add this to html files generated with pandoc.
*/
html {
font-size: 100%;
overflow-y: scroll;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
//
// ViewController.m
// AVPlayerCaching
//
// Created by Anurag Mishra on 5/19/14.
// Sample code to demonstrate how to cache a remote audio file while streaming it with AVPlayer
//
#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
@niyazpk
niyazpk / pQuery.js
Created October 25, 2014 14:03
Add or update query string parameter
// Add / Update a key-value pair in the URL query parameters
function updateUrlParameter(uri, key, value) {
// remove the hash part before operating on the uri
var i = uri.indexOf('#');
var hash = i === -1 ? '' : uri.substr(i);
uri = i === -1 ? uri : uri.substr(0, i);
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (uri.match(re)) {
@zohar
zohar / gist:a047e265e336b329f811
Created February 24, 2015 21:38
MongoDB: Find by regular expression and run regex replace on results
/*
MongoDB: Find by regular expression and run regex replace on results
*/
db.test.find({"url": { $regex: 'http:\/\/' }}).forEach(function(doc) {
doc.url = doc.url.replace(/http:\/\/www\.url\.com/g, 'http://another.url.com');
db.test.save(doc);
});