Skip to content

Instantly share code, notes, and snippets.

jQuery('#cc_number').bind('keypress, keyup', function(){
var first = parseInt(jQuery(this).val().charAt(0), 10);
if(first==3) //amex
{
jQuery('#cc_ax').attr('checked', 'checked');
}
else if(first == 4) //visa
{
jQuery('#cc_vs').attr('checked', 'checked');
@yahelc
yahelc / Twitter Hashtag to SMS.php
Created February 15, 2011 19:09
Searches for a hashtag in a set list of users' timelines, and SMSes the contents to a number using Twilio API. Uses basic MySQL store for preventing duplicate SMSes. Uses fancy tweet entities for hashtag detection.
<?php
$link = mysql_connect('localhost', 'username', 'password');
mysql_select_db('database_name');
$users = array('user_a', 'user_b', 'user_c', 'user_d'); //twitter handles, must be public timelines
$post_array = array('To'=>('1XXX5551234'), 'From'=>('1XXX5551234')); //FROM must be a Twilio-purchased #
$followed_hashtag = 'blahblah'; //will follow #blahblah hashtag in the users tweets
foreach($users as $user)
{
$url = "http://api.twitter.com/1/statuses/user_timeline.json?screen_name=" . $user . '&include_entities=true&trim_user=true';
$user_stream = json_decode(file_get_contents($url), true);
window.onerror_old = window.onerror;
window.onerror = function (msg, url, line) {
if(window.onerror_old){ window.onerror_old(); }
_gaq = _gaq || [];
_gaq.push(['_trackEvent', 'Error Log', msg, url+'_'+line]);
};
@yahelc
yahelc / gist:1004702
Created June 2, 2011 16:02
Simpler Twitter Intents / Google Analytics Script
(function(){
var event_names = {
"click" : "" ,
"tweet" : "",
"retweet" : "source_tweet_id",
"follow" : "screen_name",
"favorite" : "tweet_id"
};
for(var event_name in event_names)
@yahelc
yahelc / gist:1062772
Created July 4, 2011 00:52
FollowTheRedirect.AppSpot.com source
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@yahelc
yahelc / gist:1125219
Last active August 25, 2016 15:15
sharedcount bookmarklet
javascript:void(function(){window.open("https://www.sharedcount.com/#url="+encodeURIComponent(location.href));}());
@yahelc
yahelc / jsfiddle-jquery-defaults.user.js
Created September 8, 2011 13:36 — forked from mathiasbynens/jsfiddle-defaults.user.js
Userscript that enables jQuery-friendly defaults for jsFiddle.
// ==UserScript==
// @name Sensible defaults for jsFiddle.
// @author Mathias Bynens <http://mathiasbynens.be/>
// @modified-by Yahel Carmon
// @link http://mths.be/bde
// @match http://jsfiddle.net/*
// ==/UserScript==
if(window.location.pathname === "/") //only on new Fiddles
{
@yahelc
yahelc / gist:1227501
Created September 19, 2011 20:22
Twitter Intents Events + Google Analytics Track Social
if (window.twttr) {
var event_names = ["click", "tweet","retweet","follow","favorite"];
for(var i = 0; i<event_names.length;i++)
{
twttr.events.bind(event_names[i], function(intent) {
if(intent)
{
var target = document.createElement("a");
target.href = decodeURIComponent(intent.target.src.match(/[&#?]url=([^&]*)/)[1]);
_gaq.push(["_trackSocial","Twitter", intent.type, target.href.replace(target.hash,""), target.pathname]);
@yahelc
yahelc / chrome-ext-use-chosen-for-harvest-project-timesheet-picker-loader-0.1.user.js
Created September 20, 2011 15:43
Use "Chosen" for Harvest Project timesheet selector
// ==UserScript==
// @name Use Chosen for Harvest Project Timesheet Selector
// @author Yahel Carmon
// @description Uses Chosen for Harvest Project Timesheet Selector. Might break if they change anything. Use at your own risk.
// @namespace https://gist.github.com/gists/1229452
// @include http://*.harvestapp.com/entry/show/*
// @include https://*.harvestapp.com/entry/show/*
// ==/UserScript==
(function(){