Skip to content

Instantly share code, notes, and snippets.

@ljepson
ljepson / git.sh
Created July 4, 2012 06:11
Create links for all files stored in git to your local dot files. You can now keep backups on git with ease.
#!/bin/bash
mkdir -p $HOME/git/dotfiles/vim;
files=("bash_profile bashrc inputrc screenrc vim vimrc zshrc");
for file in $files; do
if [[ -h $HOME/.$file ]]; then
unlink $HOME/"."$file;
elif [[ -e $HOME/.$file ]]; then
@ljepson
ljepson / html_single_quotes.vim
Created July 5, 2012 15:57
Vim search and replace example='test' to example="test"
:%s/\(\w\+=\)\('\)\([a-zA-Z0-9\#-_]\+\)\('\)/\1"\3"/egci
@ljepson
ljepson / html_no_quotes.vim
Created July 5, 2012 15:58
Vim search and replace example=test to example="test"
:%s/\(\w\+=\)\([a-zA-Z0-9\#-_]\+\)/\1"\2"/egci
@ljepson
ljepson / gvoice.old.js
Created July 6, 2012 05:48
Automate clicking "Select All" checkbox in Google Voice
setInterval(function() { if(!$jq('.jfk-checkbox-checkmark').parent().hasClass('jfk-checkbox-checked') && $jq('#gc-message-list .gc-message').html().length > 1) { $jq('.jfk-checkbox-checkmark').click(); } },1000);
@ljepson
ljepson / fast_search.js
Last active October 6, 2015 21:48
Find any element Javascript
// Put in the element you want to find.
var el = document.getElementsByTagName("a"),
// Enter your search term
st = 'whatever',
// Results will go here when done
res;
for(var i = 0; i < el.length; i++) {
// Checking to see if the returned element's innerText matches the search term
if(el[i].innerText === st) {
// Results have been saved if anything was found. You can now use the variable res to do whatever you'd like
@ljepson
ljepson / ln.sh
Created August 5, 2012 22:20
Create symlinks for my dotfiles
#!/bin/bash
ln -s ~/git/dotfiles/bash_profile ~/.bash_profile;
ln -s ~/git/dotfiles/bashrc ~/.bashrc;
ln -s ~/git/dotfiles/inputrc ~/.inputrc;
ln -s ~/git/dotfiles/screenrc ~/.screenrc;
ln -s ~/git/dotfiles/vimrc ~/.vimrc;
ln -s ~/git/dotfiles/zshrc ~/.zshrc;
@ljepson
ljepson / gvoice.js
Created November 25, 2012 22:30
Google Voice Delete
var voice = {
jquery: '//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js',
key_name: '_rnr_se',
key_value: function() {return jQuery('input[name="'+ voice.key_name +'"]').val()},
page: 1,
messages: [],
done: false,
init: function() {
var script = document.createElement('script'),
head = document.getElementsByTagName('head')[0];
@ljepson
ljepson / godville.js
Created December 1, 2012 04:23
GodvilleGame.com Autobot
var godville = {
delay: 3000,
init: function() {
$('body').append('<aside id="autobot">');
$('#autobot').append('<p>Select an option from below to start botting</p>');
$('#autobot').append('<input type="radio" id="auto_encourage" name="autobot"><label for="auto_encourage">Automatically encourage</label>');
$('#autobot').append('<input type="radio" id="auto_punish" name="autobot"><label for="auto_punish">Automatically punish</label>');
$('#autobot').append('<button>Stop autoing</button>');
$('#autobot').css({
background: 'rgba(255,255,255,.45)',
@ljepson
ljepson / bing.js
Created December 14, 2012 06:09
Automatically do the amount of searches necessary to get the maximum number of daily credits from bing.com.
var bing = {
credits: 0,
current_status: function() {
var current_credits = bing.credits;
jQuery.ajax({url: '/rewards/dashboard', success: function(d) {
var credits = jQuery(d).find('.title:contains("Search Bing")').closest('a').find('.progress').text();
if(!credits.match(/.*of.*/)) bing.settings['stop'] = true;
bing.credits = Number(credits.replace(/(\d+).*/,'$1'));
bing.total = Number(jQuery(d).find('.user-balance .data-value-text:first').text());
}, complete: function() {
@ljepson
ljepson / random_selector.js
Created December 14, 2012 07:58
Select a number at random based on the frequency that it randomly showed up.
Array.prototype.frequency = function() {
this.sort();
var i = 0, array, count, item, first = this.slice(0);
while(i < first.length) {
count = 1; item = first[i]; array = i + 1;
while(array < first.length && (array = first.indexOf(item, array)) !== -1) {
count += 1; first.splice(array,1);
}
first[i] += ' : '+ count; i++;
}