Skip to content

Instantly share code, notes, and snippets.

View erikwco's full-sized avatar
💻
building the next world wide hit!

Erik Chacon erikwco

💻
building the next world wide hit!
View GitHub Profile
@emad-elsaid
emad-elsaid / now-playing.rb
Created March 25, 2014 14:31
Get your twitter Now playing stream
#!/usr/bin/env ruby
# Author : Emad Elsaid (https://github.com/blazeeboy)
# Idea of : Thibault (@EyeWriteCode)
require 'Twitter' #gem install twitter
begin
# Create a read application from :
# https://apps.twitter.com
# authenticate it for your account
# fill in the following
config = {
@emad-elsaid
emad-elsaid / moving-line.rb
Created March 26, 2014 13:31
Draw a Moving line with mouse using Ruby and Gosu gem
#!/usr/bin/env ruby
# Author : Emad Elsaid (https://github.com/blazeeboy)
require 'gosu'
include Gosu
$dimension = 200
$line_limit = 70
class GameWindow < Window
@emad-elsaid
emad-elsaid / coderwall.rb
Created March 29, 2014 12:56
Submit Protip to Coderwall.com using Selenium each day i hae to sumit to several social networks including Facebook, twitter, google+, linkedin, coderwall, and several other websites. this is alot of time spent on the same steps over and over, some websites doesn't have API to submit like Coderwall for example, so i have to simulate my behaviour…
#!/usr/bin/env ruby
# Author : Emad Elsaid (https://github.com/blazeeboy)
require "selenium-webdriver" # gem install selenium-webdriver
require "highline/import" # gem install highline
def coderwall github_email, github_password, title, content, tags
driver = Selenium::WebDriver.for :firefox
driver.navigate.to "https://coderwall.com/auth/github"
@emad-elsaid
emad-elsaid / evalin.rb
Created March 30, 2014 20:21
Execute code online and return output this script is part of my quest to create a facebook bot for executing code and respond with code output in another comment, this is similar to a reddit bot. the first step is to submit code and get the output or error from a service online, i found that Eval.in is simple and free and supports json formatted…
#!/usr/bin/env ruby
# Author : Emad Elsaid (https://github.com/blazeeboy)
require 'json'
require 'open-uri'
require 'uri'
require 'net/http'
CODE_LIMIT = 10
$url = "https://eval.in/"
$languages = {
@hauleth
hauleth / railsproj.sh
Created April 20, 2014 14:36
Rails project generation script
#!/bin/bash
dir="$1"
shift 1
mkdir "$dir"
cd "$dir"
bundler init
echo "gem 'rails'" >> Gemfile
@namelessjon
namelessjon / user.rb
Created June 21, 2011 22:14
Example user with a BCrypt password
require 'bcrypt'
class User
include DataMapper::Resource
attr_accessor :password, :password_confirmation
timestamps :at
property :id, Serial
@practicingruby
practicingruby / 1_rcat_tests.rb
Last active September 27, 2015 15:47
Implementing a clone of UNIX cat in Ruby
# Task: Implement the rcat utility and get these tests to pass on a system
# which has the UNIX cat command present
# To see Gregory Brown's solution, see http://github.com/elm-city-craftworks/rcat
# Feel free to publicly share your own solutions
rrequire "open3"
working_dir = File.dirname(__FILE__)
gettysburg_file = "#{working_dir}/data/gettysburg.txt"
class MyApplication < Sinatra::Base
use Rack::Session::Cookie
use Warden::Manager do |manager|
manager.default_strategies :password
manager.failure_app = MyApplication
end
Warden::Manager.serialize_into_session{ |user| user.id }
@johan
johan / remac.zsh
Last active July 4, 2016 13:09
osx mac address changer
function remac() {
local progress='.oO°Oo'
local airport=/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport
local ssid=$($airport -I|awk '/^ *SSID/ {print $2}')
local iface=$(networksetup -listallhardwareports|grep -A1 Wi-Fi|awk '/Device:/ {print $2}')
local mac=${1:-00$(openssl rand -hex 5|sed 's/\(..\)/:\1/g')}
echo Disconnecting Wi-Fi $iface from SSID $ssid to set new mac address $mac...
sudo $airport -z
local i n=0
@davidthewatson
davidthewatson / ext.py
Created January 19, 2012 06:48
File upload with Flask
import os
from PIL import Image
from flask import Flask, request, redirect, url_for
from werkzeug import secure_filename
from flaskext.uploads import (UploadSet, configure_uploads, IMAGES,
UploadNotAllowed)
app = Flask(__name__)
app.config['UPLOADED_PHOTOS_DEST'] = '/tmp/testuploadext'