Skip to content

Instantly share code, notes, and snippets.

@JoeGermuska
JoeGermuska / csvcut
Created September 14, 2009 17:56
Like cut, but smart about CSV quoting
#!/usr/bin/env python
"""
Like cut, but for CSVs. To be used from a shell command line.
Change row[1] to the row index to be printed. row[1] will print the second
item in the row.
Note that fields are zero-based, as opposed to 'cut' where they are 1-based.
Leveraged from/motivated by an example from @bycoffe
@smasty
smasty / 01.php
Created June 6, 2011 22:33
10 PHP One Liners to Impress Your Friends - http://smasty.net/blog/10-php-oneliners
<? foreach(range(1, 10) as $i) echo $i * 2 . " ";
@udzura
udzura / almost-sinatra.rb
Created November 29, 2011 06:36
expanding almost-sinatra.rb
%w(rack tilt backports).map do |lib|
require lib
end
%w(INT TERM).map do |sig|
trap(sig){ $r.stop }
end
Sinatra = Module.new {
extend Rack
a = (Application = Builder.new)
@dex4er
dex4er / 10_oneliners.ls
Last active January 19, 2018 21:08
10 Perl One Liners to Impress Your Friends
global import require 'prelude-ls'
# or "lsc -d" command
# 1. Multiple Each Item in a List by 2
list = [1 to 10] |> map (* 2)
list.for-each (n) !-> console.log n
# 2. Sum a List of Numbers
n = sum [1 to 1000]
console.log n
@vasilisvg
vasilisvg / HTML-presentation-tools.md
Created January 14, 2012 13:53
HTML presentation tools

#HTML presentation tools

There are many HTML presentation tools and they are all created for slightly different reasons. Here's an overview. Please let me know if I forgot any.

##CSSS

CSS-based SlideShow System

@shawndrost
shawndrost / application.rb
Created January 17, 2012 23:48 — forked from dgb/application.rb
Single file Rails application
# the new and improved one-file rails app -- now including
require "action_controller/railtie"
class Tester < Rails::Application
config.session_store :cookie_store, :key => '_rails_session'
config.secret_token = '095f674153982a9ce59914b561f4522a'
end
class UsersController < ActionController::Base
@maxivak
maxivak / resize_nocrop_noscale
Last active September 24, 2024 09:17
Crop and resize an image using MiniMagick in Ruby on Rails. Two approaches.
def resize_nocrop_noscale(image, w,h)
w_original = image[:width].to_f
h_original = image[:height].to_f
if w_original < w && h_original < h
return image
end
# resize
image.resize("#{w}x#{h}")
@karmi
karmi / Gemfile
Last active August 4, 2021 13:53 — forked from rkh/Gemfile
Sinatra + EventSource JavaScript Streaming
source "http://rubygems.org/"
gem "sinatra", "~> 1.3.0"
gem "thin"
@janko
janko / file_reading.java
Last active September 30, 2018 08:09
Java vs Ruby (#1) -- File reading.
// Java
import java.util.BufferedReader;
import java.util.FileReader;
import java.util.IOException;
String content = new String();
try {
BufferedReader reader = new BufferedReader(FileReader.new(filename));
String line;
while ((line = reader.readLine()) != null) {
@tomtaylor
tomtaylor / base58.rb
Created April 25, 2013 06:48
Base58 encoder and decoder in Ruby, suitable for converting to/from Flickr short URLs.
module Base58
class InvalidCharacterError < RuntimeError; end
ALPHABET =
%w(
1 2 3 4 5 6 7 8 9
a b c d e f g h i
j k m n o p q r s
t u v w x y z A B