Skip to content

Instantly share code, notes, and snippets.

View arikfr's full-sized avatar

Arik Fraimovich arikfr

View GitHub Profile
import Skype4Py
skype = Skype4Py.Skype()
skype.Attach()
number = '+972...'
sms = skype.CreateSms(Skype4Py.smsMessageTypeOutgoing, number)
sms.Body = 'Test SMS from Python!'
sms.Send()
@arikfr
arikfr / gist:110940
Created May 13, 2009 08:53
Teapot the PHP version
/*
See: http://www.arikfr.com/blog/how-to-create-a-teapot-with-php.html for more details.
Thanks to @toolmantim for the inspiration (http://toolmantim.com/articles/im_a_little_teapot)
*/
$method = $_SERVER['REQUEST_METHOD'];
if ($method == 'BREW') {
header("HTTP/1.1 418 I'm a teapot");
die("We do serve ICE Tea, though.\n");
@arikfr
arikfr / mapper.py
Created December 7, 2009 17:07
Mapper base class using deferred tasks. Based on an example code by Nick Johnson (http://code.google.com/appengine/articles/deferred.html)
from google.appengine.ext import deferred
from google.appengine.runtime import DeadlineExceededError
class Mapper(object):
# Subclasses should replace this with a model class (eg, model.Person).
KIND = None
# Subclasses can replace this with the property the entities should be ordered by.
ORDER_BY = '__key__'
import base64
from django.utils import simplejson
import urllib
from google.appengine.api import urlfetch
def track(event, properties=None):
"""
A simple function for asynchronously logging to the mixpanel.com API on App Engine
(Python) using RPC URL Fetch object.
@param event: The overall event/category you would like to log this data under
@arikfr
arikfr / .monitrc
Created December 13, 2010 14:35
Setting Monit to work with Gmail as mail server
set mailserver smtp.gmail.com port 587 username "user@domain.com" password "password" using tlsv1 with timeout 30 seconds
@arikfr
arikfr / pulse.term
Created March 11, 2011 18:57
My terminitor definitions for Pulse
window do
before { run 'cd ~/dev/Wix/rails3' }
tab "rails server" do
run 'rails s thin --debugger'
end
tab "solr" do
run 'rake sunspot:solr:run'
end
Asset.find_in_batches do |group|
group.each do |asset|
if asset.is_image?
current_url = asset.resource.path
new_url = asset.resource.path(:large)
if AWS::S3::S3Object.exists? current_url, S3Config['bucket_name']
begin
AWS::S3::S3Object.copy current_url, new_url, S3Config['bucket_name'], :copy_acl => :true
puts "File copied [#{current_url}] => [#{new_url}]."
@arikfr
arikfr / rails3_template.rb
Created July 8, 2011 08:50
My Rails projects template
# create rvmrc file
create_file ".rvmrc", "rvm use 1.9.2-patched@#{app_name}"
run "rvm gemset create #{app_name}"
run "rvm use 1.9.2-patched@#{app_name}"
gem "compass"
gem 'compass-less-plugin'
gem 'barista'
gem "jquery-rails"
@arikfr
arikfr / class_methods.coffee
Created July 10, 2011 09:58
Class Methods example in CoffeeScript
class Utils
@stripTags: (html) ->
html.replace(/<\/?[^>]+>/gi, '')
alert(Utils.stripTags('<html>test</html>'));
@arikfr
arikfr / gist:1118210
Created August 1, 2011 14:21
Guard/Spork talk

###The Problem

$ time rails runner "puts 1"
1

real	0m14.917s
user	0m10.923s
sys	0m3.007s[/code]