Skip to content

Instantly share code, notes, and snippets.

@r4vi
r4vi / chkadm.py
Created April 12, 2011 11:10
checks if the current logged in user is removed from the local administrators group and re-adds. (windows)
import ctypes
import win32net, win32api
import time
current_user = win32api.GetUserNameEx(2)
data = [{"domainandname": current_user}]
def get_members(group_name):
members = win32net.NetLocalGroupGetMembers(None, group_name, 3)[0]
print members
@samuelclay
samuelclay / image_dominant_color.py
Created April 14, 2011 01:21
Algorithm to find the dominant color in an image.
from PIL import Image
import scipy
import scipy.cluster
from pprint import pprint
image = Image.open('logo_newsblur_512.png')
NUM_CLUSTERS = 15
# Convert image into array of values for each point.
ar = scipy.misc.fromimage(image)
@jolby
jolby / core.cljs
Created August 2, 2011 00:12
Clojurescript on Appcelerator Titanium
(ns tiexample.core)
(defn ^{:export dbg} dbg [s]
(js* "Titanium.API.debug(~{s})"))
;;stolen from another gist I saw
(defn make-js-map
"makes a javascript map from a clojure one"
[cljmap]
(let [out (js-obj)]
@alvinl
alvinl / vpn.sh
Created April 21, 2012 20:45
Script to install pptp on Debian 6
#!/bin/bash
apt-get update
apt-get install pptpd -y
echo localip 192.168.240.1 >> /etc/pptpd.conf
echo remoteip 192.168.240.2-9 >> /etc/pptpd.conf
echo ms-dns 8.8.8.8 >> /etc/ppp/pptpd-options
echo ms-dns 8.8.4.4 >> /etc/ppp/pptpd-options
echo "vpn pptpd pass123 *" | tee -a /etc/ppp/chap-secrets
/etc/init.d/pptpd restart
@trongthanh
trongthanh / gist:2779392
Last active April 24, 2024 23:46
How to move a folder from one repo to another and keep its commit history
# source: http://st-on-it.blogspot.com/2010/01/how-to-move-folders-between-git.html
# First of all you need to have a clean clone of the source repository so we didn't screw the things up.
git clone git://server.com/my-repo1.git
# After that you need to do some preparations on the source repository, nuking all the entries except the folder you need to move. Use the following command
git filter-branch --subdirectory-filter your_dir -- -- all
# This will nuke all the other entries and their history, creating a clean git repository that contains only data and history from the directory you need. If you need to move several folders, you have to collect them in a single directory using the git mv command.
@ibrahima
ibrahima / request_queue.py
Created July 20, 2012 22:21
A silly class that lets you use Grequests in a somewhat similar manner as the ruby gem Typhoeus
import grequests
from collections import deque
class RequestQueue(object):
"""
This is a lame imitation of a Typhoeus Hydra using GRequests.
The main thing this allows is building up a queue of requests and then
executing them, and potentially adding requests to the queue in a callback
so that you can build requests that depend on other requests more naturally.
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@tgecho
tgecho / readme.txt
Created December 11, 2012 18:13
LiveReload compatibility hack for Webassets
Tested with LiveReload 2.3.18
The only requirement is that the updating requests are sent with ?livereload={etc} in the url.
LiveReload should be configured to NOT compile the assets, as we want webassets to take care of this. We're
just using LR for the notification/loading parts.
(ns react-cljs.core
(:require React))
(declare render)
(defn handle-change [e]
(render {:text (.. e -target -value)}))
(defn render [{:keys [text]}]
(React/renderComponent
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active April 25, 2024 02:01
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results