Skip to content

Instantly share code, notes, and snippets.

View automaticalldramatic's full-sized avatar
🦊
this is a useless feature

riz automaticalldramatic

🦊
this is a useless feature
View GitHub Profile
require 'rubygems'
require 'nokogiri'
require 'open-uri'
site = ARGV[0]
doc = Nokogiri::HTML(open("http://www.alexa.com/siteinfo/#{site}"))
data = []
doc.css('ul')[4].css('li.geo_percentages').each_with_index do |raw,i|
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active March 8, 2024 02:11
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@juliocesar
juliocesar / best-localStorage-polyfill-evar.js
Created April 18, 2011 23:19
This is the best localStorage polyfill in the world
// I mean, seriously, localStorage is supported even by your mum. How about instead of
// casing the feature out, you give users in-memory (stale) storage instead?
// If they close your application, they deserve to lose data anyway.
// if (!('localStorage' in window)) {
if (!Modernizr.localstorage) {
window.localStorage = {
_data : {},
setItem : function(id, val) { return this._data[id] = String(val); },
getItem : function(id) { return this._data.hasOwnProperty(id) ? this._data[id] : undefined; },
@dblock
dblock / getWeek.js
Created July 13, 2011 22:49
get week of the year in JavaScript
function( d ) {
// Create a copy of this date object
var target = new Date(d.valueOf());
// ISO week date weeks start on monday
// so correct the day number
var dayNr = (d.getDay() + 6) % 7;
// Set the target to the thursday of this week so the
@bcoles
bcoles / alexa-rank.rb
Created September 19, 2011 04:16
Alexa Rank - Retrieves the Alexa rank for domain(s)
#!/usr/bin/env ruby
# Alexa Rank
# Retrieves the Alexa rank for domain(s)
# 2011-09-19 # bcoles@gmail.com
##
verbose = true
version = "0.1"
# Usage
@artero
artero / launch_sublime_from_terminal.markdown
Last active January 25, 2024 16:57 — forked from olivierlacan/launch_sublime_from_terminal.markdown
Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@wilvandertuin
wilvandertuin / pasz.js
Created January 10, 2012 19:34
Bare jQuery plugin using revealing module pattern
/**
* Minimum set up for a revealing module pattern jQuery plugin
*
* This is a bare plugin that uses the revealing module pattern to attach
* public and private vars and methods to a jQuery selector.
*
* Example:
*
* $('#menu').collapsible().init();
* $('#menu').collapsible().open();
@chasewoodford
chasewoodford / style.scss
Created June 16, 2012 02:12 — forked from saucer-jp/style.scss
sass:mixin fadeIn
$prefix:'-moz-', '-webkit-', '-o-', '-ms-', '';
// ********************
// fadeIn
// ********************
@mixin keyframe-fadeIn {
0% { opacity:0; }
100% { opacity:1; }
}
@-moz-keyframes fadeIn {
@include keyframe-fadeIn;
@masnun
masnun / alexa.py
Created July 24, 2012 16:02
Python One-liner to get your site's Alexa Rank
#!/usr/bin/env python
import urllib, sys, bs4
print bs4.BeautifulSoup(urllib.urlopen("http://data.alexa.com/data?cli=10&dat=s&url="+ sys.argv[1]).read(), "xml").find("REACH")['RANK']
@markthiessen
markthiessen / getWeeksInMonth.js
Last active April 25, 2024 02:05
JavaScript - get weeks in a month as array of start and end days
//note: month is 0 based, just like Dates in js
function getWeeksInMonth(year, month) {
const weeks = [],
firstDate = new Date(year, month, 1),
lastDate = new Date(year, month + 1, 0),
numDays = lastDate.getDate();
let dayOfWeekCounter = firstDate.getDay();
for (let date = 1; date <= numDays; date++) {