Skip to content

Instantly share code, notes, and snippets.

View lanrion's full-sized avatar
🎯
Focusing

lanrion lanrion

🎯
Focusing
  • guǎng zhōu
View GitHub Profile
@agibralter
agibralter / asset_fingerprints.rb
Created May 25, 2011 19:39
Using Jammit and asset_hash with Rails 2.3.11 (Also, using my fork of asset_hash to avoid a Rails 3.x `require` conflict: https://github.com/agibralter/asset_hash)
# lib/asset_fingerprints.rb -- A hack to get asset_hash to play nice with Rails 2.3.11 (since there is no ActionController::Base.asset_path configuration option).
# Same as deployment nginx configuration.
# No font/woff because it is already compressed:
# http://www.pixelastic.com/blog/87:gzipping-your-font-files
AssetHash::Base.gzip_types = %w(
application/javascript
application/json
application/xml
@jhummel
jhummel / gist:1338318
Created November 4, 2011 00:09
Make ujs-jquery for rails work with Zepto
// Fix to make zepto work with ujs-jquery
$.fn.ajaxSend = function(callback) {
return this.each(function(){
$(this).on('ajaxBeforeSend', callback);
});
};
var jQuery = $;
<?php
/**
* Geohash
*
* @author Keisuke SATO
* @license MIT License
*
* # Based
* http://github.com/davetroy/geohash-js/blob/master/geohash.js
* Geohash library for Javascript
class ApplicationController < ActionController::Base
...
#Problem:
#In rails 3.0.1+ it is no longer possible to do this anymore;
# rescue_from ActionController::RoutingError, :with => :render_not_found
#
#The ActionController::RoutingError thrown is not caught by rescue_from.
#The alternative is to to set a catch-all route to catch all unmatched routes and send them to a method which renders an error
#As in http://techoctave.com/c7/posts/36-rails-3-0-rescue-from-routing-error-solution
@rust-play
rust-play / playground.rs
Created October 10, 2019 08:19
Code shared from the Rust Playground
use std::fmt::Debug;
//trait ReturnType: Debug + Clone {}
//
//impl ReturnType for String {}
//impl ReturnType for i32 {}
#[derive(Debug)]
enum Command {
Create,
@ziadoz
ziadoz / compile.sh
Created July 17, 2012 17:51
Upgrade Ubuntu 10.04 to PHP 5.4.8
# Install Dependencies
# sudo apt-get install build-essential
# sudo apt-get build-dep php5
sudo apt-get install libmysqlclient-dev mysql-client libcurl4-openssl-dev libgd2-xpm-dev libjpeg-dev libpng3-dev libxpm-dev libfreetype6-dev libt1-dev libmcrypt-dev libxslt1-dev bzip2 libbz2-dev libxml2-dev libevent-dev libltdl-dev libmagickwand-dev libmagickcore-dev imagemagick libreadline-dev libc-client-dev libsnmp-dev snmpd snmp libvpx-dev libxpm-dev libgmp3-dev libicu-dev libpspell-dev libtidy-dev freetds-dev unixodbc-dev librecode-dev libglib2.0-dev libsasl2-dev libgeoip-dev imagemagick libmagickcore-dev libmagickwand-dev
# Stop Apache
sudo service apache2 stop
# Cleanup Packages
sudo apt-get autoremove
@jeffyip
jeffyip / rails_json_cookie_session_store.rb
Last active September 23, 2020 07:03
Monkey Patch Ruby on Rails' cookie based session store to use JSON as its serializer instead of Marshal
@tyvsmith
tyvsmith / Setting.rb
Created June 5, 2011 20:42
Dynamic changes to schedule.rb for Whenever gem
class Setting < ActiveRecord::Base
validates_uniqueness_of :var
validates_presence_of :value
after_save :send_cron_later
#Setting.for(:display).set=(value)
def self.for(var)
find_or_create_by_var(var)
@dbainbridge
dbainbridge / app.js
Created April 19, 2012 20:48
How to use socket.io with Express 3
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, http = require('http');
var app = express();
var server = app.listen(3000);
@srt32
srt32 / install.md
Last active July 18, 2021 23:43
installing PostGIS on OSX

Installing the Postgres PostGIS extension on OSX

For reference: http://postgis.net/install

If you don’t already have PG installed

The most reliable way to get PostGIS on OSX is to download and install Postgres.app. Great for development and testing. Do not mix with other installations. Select the extension when prompted.

If you already have PG installed