Skip to content

Instantly share code, notes, and snippets.

View batandwa's full-sized avatar

Batandwa batandwa

View GitHub Profile
@crittermike
crittermike / gist:6a24108a65407676497e
Created June 24, 2014 15:07
Parse a tweet's text with PHP and regex
<?php
/**
* Regex taken from http://saturnboy.com/2010/02/parsing-twitter-with-regexp/
*/
function parse_tweet($text) {
// Parse links.
$text = preg_replace(
'@(https?://([-\w\.]+)+(/([\w/_\.]*(\?\S+)?(#\S+)?)?)?)@',
'<a href="$1">$1</a>',
@johndstein
johndstein / mongo-ansible.yml
Created June 7, 2014 03:51
Ansible install mongodb
# Install mongodb
---
- name: Add mongo ppa key
sudo: yes
apt_key: >
keyserver=hkp://keyserver.ubuntu.com:80
id=7F0CEB10
state=present
- name: Add mongo sources list
@lukesutton
lukesutton / jquery.plugin.js
Created October 29, 2013 23:26
Scaffold for a jQuery plugin.
(function($) {
function Plugin($el, opts) {
this.$el = $el;
this.settings = $.extend({
// Add default settings here.
}, opts);
}
Plugin.prototype = {
@CSEmbree
CSEmbree / hello.py
Created October 14, 2013 03:54
hello world code in Python
#!/usr/bin/python
# Run with:
# python hello.py cameron
# python hello.py
# import modules used here -- sys is a very standard one
import sys
ssh-reagent () {
for agent in /tmp/ssh-*/agent.*; do
export SSH_AUTH_SOCK=$agent
if ssh-add -l 2>&1 > /dev/null; then
echo Found working SSH Agent:
ssh-add -l
return
fi
done
echo Cannot find ssh agent - maybe you should reconnect and forward it?
@mbostock
mbostock / .block
Last active March 1, 2024 06:07
The Gist to Clone All Gists
license: gpl-3.0
@Dreyer
Dreyer / mail-test.php
Created June 20, 2012 09:06
Quick & Dirty PHP Mail Test Script
<?php
/*
DONT FORGET TO DELETE THIS SCRIPT WHEN FINISHED!
*/
ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
$from = 'webmaster@example.com';
@agibsonsw
agibsonsw / hide_element
Created February 5, 2012 16:35
JS Bookmarklet to hide an element on click
javascript:(function(){var%20d=document,useMine=true,prevEl;function%20AddHandler(orig,mine)
{return%20function(e){if(useMine)mine(e);else%20if(orig)orig(e);};}function%20Myonmouseover(e)
{var%20evt=e||window.event;var%20elem=evt.target||evt.srcElement;elem.style.outline='2px%20solid%20gray';
prevEl=elem;}function%20Myonmouseout(e){var%20evt=e||window.event;var%20elem=evt.target||evt.srcElement;elem.style.outline='';}
function%20Myonclick(e){var%20evt=e||window.event;var%20elem=evt.target||evt.srcElement;elem.style.display='none';}
function%20Myonkeydown(e){var%20evt=e||window.event;if(evt.keyCode==27){prevEl.style.outline='';useMine=false;}}
d.onmouseover=AddHandler(d.onmouseover,Myonmouseover);d.onmouseout=AddHandler(d.onmouseout,Myonmouseout);
d.onclick=AddHandler(d.onclick,Myonclick);d.onkeydown=AddHandler(d.onkeydown,Myonkeydown);})()
@rezlam
rezlam / ssh-agent
Created March 2, 2011 12:29
Put this code in .bashrc or .profile to start ssh-agent automatically (tested with Git Bash on Windows 7).
SSH_ENV="$HOME/.ssh/environment"
# start the ssh-agent
function start_agent {
echo "Initializing new SSH agent..."
# spawn ssh-agent
ssh-agent | sed 's/^echo/#echo/' > "$SSH_ENV"
echo succeeded
chmod 600 "$SSH_ENV"
. "$SSH_ENV" > /dev/null
@jgv
jgv / opacity.scss
Last active March 26, 2017 21:42
Cross-browser sass/scss mixin for opacity down to IE 5
@mixin hp-opacity($trans) {
filter: alpha(opactiy=($trans * 100));
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=#{$trans * 100})";
-moz-opacity: $trans;
-khtml-opacity: $trans;
opacity: $trans;
}