Skip to content

Instantly share code, notes, and snippets.

@creationix
creationix / scraper.js
Created August 23, 2010 05:12
Simple scraper tool
var http = require('http'),
Url = require('url'),
htmlparser = require('node-htmlparser'),
dom = require('jsdom/level1/core').dom.level1.core,
index = require('jsdom/browser/index'),
sizzleInit = require('sizzle').sizzleInit;
// Simple wrapper around node's http client, htmlparser, jsdom, and sizzle
function fetch(url, callback) {
var uri = Url.parse(url);
@pamelafox
pamelafox / selenium_dom.py
Created January 17, 2012 02:36
Python Selenium Dom Helper Functions
from selenium.common.exceptions import NoSuchElementException, TimeoutException
class DomHelper(object):
driver = None
waiter = None
def open_page(self, url):
self.driver.get(url)
@them0nk
them0nk / rspec_rails_cheetsheet.rb
Created March 23, 2012 03:39
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@bonnici
bonnici / ZombieBot_QaDBFRvR.py
Created December 2, 2012 01:05
Quick-and-Dirty Brute Force Risk vs Reward bot
# Quick-and-Dirty Brute Force Risk vs Reward bot
# Before each roll (except the first), do a brute force calculation of risk vs reward. In this case,
# risk is the probability of having 3 shotgun dice after the roll, and reward is the probability of
# getting an extra 1, 2, or 3 brains. If P(death) - rewardBonus[1]*P(1 brain) -
# rewardBonus[2]*P(2 brain) - rewardBonus[3]*P(3 brain) > rvrCutoff, then roll.
# If behindBonus and/or aheadPenalty are not zero, then those amounts are added to or subtracted from
# the risk vs reward depending on weather the bot is winning or losing, encouraging risky play when
# behind and safer play when ahead
@senny
senny / builders.py
Created May 24, 2013 08:58
A Builder Pattern implementation to create test data objects in Plone
from plone.dexterity.utils import createContentInContainer
from plone.namedfile.file import NamedBlobFile
import transaction
def Builder(name):
if name == "dossier":
return DossierBuilder(BuilderSession.instance())
elif name == "document":
return DocumentBuilder(BuilderSession.instance())
elif name == "task":
@tomas-stefano
tomas-stefano / Capybara.md
Last active July 3, 2024 12:47
Capybara cheatsheet

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active July 23, 2024 04:22
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@P7h
P7h / jdk_download.sh
Last active May 21, 2024 02:10
Script to download JDK / JRE / Java binaries from Oracle website from terminal / shell / command line / command prompt
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
### Shell script to download Oracle JDK / JRE / Java binaries from Oracle website using terminal / command / shell prompt using wget.
### You can download all the binaries one-shot by just giving the BASE_URL.
### Script might be useful if you need Oracle JDK on Amazon EC2 env.
### Script is updated for every JDK release.
### Features:-
# 1. Resumes a broken / interrupted [previous] download, if any.
# 2. Renames the file to a proper name with including platform info.
#!/bin/bash
# Backs up the OpenShift PostgreSQL database for this application
# by Skye Book <skye.book@gmail.com>
NOW="$(date +"%Y-%m-%d")"
FILENAME="$OPENSHIFT_DATA_DIR/$OPENSHIFT_APP_NAME.$NOW.backup.sql.gz"
find $OPENSHIFT_DATA_DIR -name $OPENSHIFT_APP_NAME.*backup* -type f -mtime +30 -exec rm '{}' \;
pg_dump $OPENSHIFT_APP_NAME | gzip > $FILENAME