Skip to content

Instantly share code, notes, and snippets.

View DAddYE's full-sized avatar

Davide D'Agostino DAddYE

  • Uber
  • San Francisco
View GitHub Profile
@DAddYE
DAddYE / randomID.go
Created July 30, 2015 18:38
Generate pseudo random numbers
package main
import (
"crypto/rand"
"math/big"
)
var maxID = new(big.Int).SetUint64(^uint64(0))
func genRandomID() uint64 {
@DAddYE
DAddYE / example.rb
Last active August 29, 2015 14:26 — forked from hamin/example.rb
An updated Rust 1.x version of Yehuda's Native Rust Extension post here http://blog.skylight.io/bending-the-curve-writing-safe-fast-native-gems-with-rust/
require "./points"
p1 = RustPoint::make_point(10, 10) # => #<Fiddle::Pointer:0x007f8231e56510 ptr=0x0000010b824000 size=0 free=0x00000000000000>
p2 = RustPoint::make_point(20, 20) # => #<Fiddle::Pointer:0x007f8231f20970 ptr=0x0000010b824010 size=0 free=0x00000000000000>
RustPoint::get_distance(p1, p2) # => 14.142135623730951
# Remove old version of merb
sudo gem search --no-version merb | grep merb | xargs sudo gem uninstall -a
# Install only few gems of merb!
sudo gem install merb-core merb-action-args merb-assets merb-cache merb-exceptions merb-gen merb-haml merb-helpers merb-mailer merb-param-protection merb_activerecord
# This is an idea how it might become Lipsiadmin Grids in the future.
# In particular we focused to bring them into reusable on other pages.
def grid
grid = Ext.grid "List of all accounts" do |grid|
#Some standard config
grid.append "/backend/accounts/store.js" # or :controller => :accounts, :action => :store, :format => :js
grid.selection :checkbox
grid.grouped true, "accounts.name"# true is default
# Render:
@DAddYE
DAddYE / gist:87766
Created March 30, 2009 12:16
upgrade-to-fc10-64
#!/bin/bash
# Aggiornamento iniziale server Fedora 10 64bit
rm -rf ~/upgrading
echo "Eseguo gli aggiornamenti e pulisco la cache"
yum update -y && yum clean all
echo "Eseguo ancora una volta gli aggiornamenti e pulisco la cache"
yum update -y && yum clean all
echo "Creo la directory di upgrade"
#!/bin/bash
# Configurazione iniziale server Fedora 10 64bit
clear
echo "----------------------------------------------------"
echo "--------------Configurazione Fedora 10--------------"
echo "----------------------------------------------------"
echo
echo -n "Vuoi modificare il messaggio di login? (y/n): "; read ans
var selProductsGroupingView = new Ext.grid.GroupingView({
forceFit: true
});
var selProductsToolbar = new Ext.Toolbar();
var selProductsCheckboxSelectionModel = new Ext.grid.CheckboxSelectionModel();
var selProductsGroupingStore = new Ext.data.GroupingStore({
reader: new Ext.data.JsonReader({
# An advanced grid
#
# products_controller.rb
def show
params[:limit] ||= 50
# Our conditions
conditions = "products.store_id = #{current_store.id}"
conditions += " AND warehouses.id IN (#{current_account.warehouseship_ids.join(",")})" if current_account.magazziniere?
@DAddYE
DAddYE / gist:232861
Created November 12, 2009 12:34
Structure
We couldn’t find that file to show.
@DAddYE
DAddYE / Routing.rb
Created November 12, 2009 13:08
Routing
namespace :admin do
get :show do
...
end
end
namespace :frontend do
get :index do
...
end