Skip to content

Instantly share code, notes, and snippets.

View sowenjub's full-sized avatar
🏝️
Living in Paraside

Arnaud Joubay sowenjub

🏝️
Living in Paraside
View GitHub Profile
@kevinSuttle
kevinSuttle / meta-tags.md
Last active May 30, 2025 13:08 — forked from lancejpollard/meta-tags.md
List of Usable HTML Meta and Link Tags
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
@rduplain
rduplain / MainActivity.java
Created May 8, 2012 20:08
A very simple full-screen WebView activity for Android native wrappers, as a starting point.
package com.willowtreeapps.demo;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends Activity {
@evanbeard
evanbeard / registrations_controller.rb
Created May 11, 2012 19:53 — forked from jwo/registrations_controller.rb
API JSON authentication with Devise
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@inopinatus
inopinatus / hstore_accessor.rb
Last active June 29, 2024 17:26
hstore accessor class method for AR
# include from an initializer
module HstoreAccessor
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def hstore_accessor(hstore_attribute, *keys)
Array(keys).flatten.each do |key|
@mitio
mitio / Gemfile
Created June 12, 2012 20:21
Rails 3.2 + RSpec 2.8 + Spork + Guard + Growl
group :development, :test do
gem 'rspec-rails'
gem 'factory_girl_rails', :require => false
gem 'shoulda-matchers'
end
group :development do
gem 'guard-rspec'
gem 'guard-spork'
# For Growl notifications
@sandys
sandys / table_to_csv.rb
Created October 18, 2012 10:04
convert a html table to CSV using ruby
# run using ```rvm jruby-1.6.7 do jruby "-J-Xmx2000m" "--1.9" tej.rb```
require 'rubygems'
require 'nokogiri'
require 'csv'
f = File.open("/tmp/preview.html")
doc = Nokogiri::HTML(f)
csv = CSV.open("/tmp/output.csv", 'w',{:col_sep => ",", :quote_char => '\'', :force_quotes => true})
@benvium
benvium / example.h
Created November 29, 2012 13:21
Adding and catching links in a UILabel on iOS5 when you're designing with Interface Builder / Storyboards.
#import "TTTAttributedLabel.h"
@interface CVSignupViewController : UITableViewController <TTTAttributedLabelDelegate> {
IBOutlet TTTAttributedLabel* _legalLabel;
}
@end
@justinHowlett
justinHowlett / gist:4611988
Last active July 9, 2024 11:53
Determine if a UIImage is generally dark or generally light
BOOL isDarkImage(UIImage* inputImage){
BOOL isDark = FALSE;
CFDataRef imageData = CGDataProviderCopyData(CGImageGetDataProvider(inputImage.CGImage));
const UInt8 *pixels = CFDataGetBytePtr(imageData);
int darkPixels = 0;
int length = CFDataGetLength(imageData);
@joost
joost / google_timezone.rb
Created January 30, 2013 19:50
Get time zone id of a location by latitude and longitude (lat, lng).
# See: https://developers.google.com/maps/documentation/timezone/
# Uses HTTParty gem (https://github.com/jnunemaker/httparty).
# Usage:
# GoogleTimezone.search(:lat => 51.38494009999999, :lng => -0.3514683)['timeZoneId']
class GoogleTimezone
include HTTParty
base_uri 'https://maps.googleapis.com'