Skip to content

Instantly share code, notes, and snippets.

View MacroMan's full-sized avatar

David Wakelin MacroMan

View GitHub Profile
@jxson
jxson / README.md
Created February 10, 2012 00:18
README.md template

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Motivation

@adrienbrault
adrienbrault / purge.sh
Created September 24, 2012 10:02
Script to reduce VM size before packaging for vagrant
#!/bin/sh
# Credits to:
# - http://vstone.eu/reducing-vagrant-box-size/
# - https://github.com/mitchellh/vagrant/issues/343
aptitude -y purge ri
aptitude -y purge installation-report landscape-common wireless-tools wpasupplicant ubuntu-serverguide
aptitude -y purge python-dbus libnl1 python-smartpm python-twisted-core libiw30
aptitude -y purge python-twisted-bin libdbus-glib-1-2 python-pexpect python-pycurl python-serial python-gobject python-pam python-openssl libffi5
@DiegoSalazar
DiegoSalazar / validate_credit_card.js
Last active April 24, 2024 12:51
Luhn algorithm in Javascript. Check valid credit card numbers
// Takes a credit card string value and returns true on valid number
function valid_credit_card(value) {
// Accept only digits, dashes or spaces
if (/[^0-9-\s]+/.test(value)) return false;
// The Luhn Algorithm. It's so pretty.
let nCheck = 0, bEven = false;
value = value.replace(/\D/g, "");
for (var n = value.length - 1; n >= 0; n--) {
@rehno-lindeque
rehno-lindeque / switch_huwai_modem.sh
Created January 10, 2013 08:39
Script to switch a Huawei Modem (E173 I think?) from Mass Storage to Modem in Ubuntu using usb_modeswitch
# Script to switch a Huawei Modem from Mass Storage to Modem in Ubuntu using usb_modeswitch
# (after inserting usb, run repeatedly until device is switched to modem.
# If you wait too long device wont switch and you need to remove it,
# reconnect the usb device and run script again)
# Btw. If you stumble on this while looking for a solution to your Huawei modem problems... There may be better ways:
# https://help.ubuntu.com/community/DialupModemHowto/Huawei
# http://askubuntu.com/questions/179324/huawei-e173-on-ubuntu-12-04
# http://ubuntuforums.org/showthread.php?t=1605484
@brucekirkpatrick
brucekirkpatrick / jquery.unserialize.js
Last active March 11, 2018 22:59 — forked from rcmachado/jquery.unserialize.js
Takes a string in format "param1=value1&param2=value2" and returns an javascript object. Improved to handle multiple values with same name and to unescape url encoded values.
/**
* $.unserialize
*
* Takes a string in format "param1=value1&param2=value2" and returns an object { param1: 'value1', param2: 'value2' }. If the "param1" ends with "[]" the param is treated as an array.
*
* Example:
*
* Input: param1=value1&param2=value2
* Return: { param1 : value1, param2: value2 }
*
@WintersMichael
WintersMichael / gist:c70d195c5c5670d1625f
Created November 10, 2014 19:43
Shell one-liner to parse apache access logs and extract a unique URL list with hit count, querystring excluded.
cat access.log | awk -F\" '{print $2}' | awk '{print $2}' | sed '/^$/d' | sed 's/\?.*//g' | sort | uniq -c | sort -rn > url_hits.txt
@joepie91
joepie91 / getting-started.md
Last active February 21, 2024 14:45
Getting started with Node.js

"How do I get started with Node?" is a commonly heard question in #Node.js. This gist is an attempt to compile some of the answers to that question. It's a perpetual work-in-progress.

And if this list didn't quite answer your questions, I'm available for tutoring and code review! A donation is also welcome :)

Setting expectations

Before you get started learning about JavaScript and Node.js, there's one very important article you need to read: Teach Yourself Programming in Ten Years.

Understand that it's going to take time to learn Node.js, just like it would take time to learn any other specialized topic - and that you're not going to learn effectively just by reading things, or following tutorials or courses. _Get out there and build things!

@shark0der
shark0der / ubuntu14.04-command-line-install-android-sdk
Last active March 7, 2021 15:09 — forked from wenzhixin/ubuntu14.04-command-line-install-android-sdk
Ubuntu 14.04 command line install android sdk (platform & platform-tools only, no emulator)
# install java
apt-get install -y software-properties-common
apt-add-repository -y ppa:webupd8team/java
apt-get update
apt-get install -y oracle-java8-installer
# download latest android sdk
# http://developer.android.com/sdk/index.html#Other
cd /opt
wget http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
@julianxhokaxhiu
julianxhokaxhiu / pagespeed_optimize_images.sh
Last active May 23, 2024 08:34
Recursively optimize all PNG and JPG files wherever they are from the script position and inner ( based on OPTING, PNGCRUSH, ADVANCECOMP and JPEGOPTIM )
#!/bin/bash
# Improved as per feedback from @pascal - https://gist.github.com/julianxhokaxhiu/c0a8e813eabf9d6d9873#gistcomment-3086462
find . -type f -iname "*.png" -exec optipng -nb -nc {} \;
find . -type f -iname "*.png" -exec advpng -z4 {} \;
find . -type f -iname "*.png" -exec pngcrush -rem gAMA -rem alla -rem cHRM -rem iCCP -rem sRGB -rem time -ow {} \;
find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" \) -exec jpegoptim -f --strip-all {} \;
@superguigui
superguigui / README.md
Last active December 13, 2022 21:38
Three-orbit-controls with rotation set methods

I added a few methods to three-orbit-controls to be able to manually define phi or theta and be able to rotate to a given point.

// rotation in Y
controls.setAzimuthalAngle(theta);

// rotation in X
controls.setPolarAngle(phi);