Skip to content

Instantly share code, notes, and snippets.

View furkanayhan's full-sized avatar

Furkan Ayhan furkanayhan

View GitHub Profile
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@petewarden
petewarden / tumblrproxy.rb
Created October 25, 2012 03:28
An example of proxying a Tumblr blog as a subdirectory in Ruby and Sinatra
get '/blog*' do
path = params[:splat][0]
source_url = 'http://yourblog.tumblr.com' + path.gsub(/ /, '+')
source_content_type = ''
source_body = open(source_url) do |f|
source_content_type = f.content_type # "text/html"
f.read
end
if source_content_type == 'text/html'
output_base = request.base_url + '/blog'
@seyhunak
seyhunak / minutes_in_words.rb
Created June 6, 2013 14:35
Ruby minutes_in_words converter
def minutes_in_words(timestamp)
timestamp = Time.at(timestamp)
minutes = (((Time.now - timestamp).abs)/60).round
return nil if minutes < 0
case minutes
when 0..1 then "less than 1 minute"
when 1..2 then "1 minute ago"
when 2..59 then "#{minutes} minutes ago"
@seyhunak
seyhunak / better_errors.js
Created July 29, 2013 13:27
Rails - Better Errors - Ajax
$(document)
.on("ajaxError", function(e, request, textStatus, errorThrown) {
window.open("/__better_errors", "error");
});
@stinoga
stinoga / index.js
Created December 23, 2013 18:05
Replacing query string parameter values.
// Update the appropriate href query string parameter
function paramReplace(name, string, value) {
// Find the param with regex
// Grab the first character in the returned string (should be ? or &)
// Replace our href string with our new value, passing on the name and delimeter
var re = new RegExp("[\\?&]" + name + "=([^&#]*)"),
delimeter = re.exec(string)[0].charAt(0),
newString = string.replace(re, delimeter + name + "=" + value);
return newString;
@emad-elsaid
emad-elsaid / share-screen.rb
Created February 22, 2014 10:30
share your screen on the local network
require 'socket'
require 'base64'
Refresh = 1 # seconds to refresh image on server
screen_capture_command = 'screencapture -C -x tmp.png'
image = ''
latest = Time.now
server = TCPServer.new 3000
loop do
@emad-elsaid
emad-elsaid / chat.rb
Created March 1, 2014 13:18
creating simple network chat using ruby
require 'sinatra' # gem install sinatra --no-rdoc --no-ri
set :port, 3000
set :environment, :production
html = <<-EOT
<html><head><style>
#text{width:100%; font-size: 15px; padding: 5px; display: block;}
</style></head><body>
<input id="text" placeholder="Write then press Enter."/>
<div id="chat"></div>
@profh
profh / decode_session_cookie.rb
Last active June 23, 2021 13:25
A simple script to decode Rails 4 session cookies
@vigo
vigo / tr-developer-podcasts.md
Last active June 9, 2017 11:11
Türkçe Developer PodCast'leri

Türkçe Developer PodCast’leri

devPod

[Web][1a] - [iTunes][1b]

webBox5

[Web][2a] - [iTunes][2b]

@tonymtz
tonymtz / gist:d75101d9bdf764c890ef
Last active July 26, 2024 20:17
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*