Skip to content

Instantly share code, notes, and snippets.

register({
name: 'moodle.domain.com',
url: 'http://moodle.domain.com/',
icon: 'http://moodle.domain.com/theme/mytheme/favicon.ico',
domains: [ 'moodle.domain.com' ],
sessionCookieNames: [ 'MoodleSession', 'MoodleSessionTest' ],
identifyUser: function() {
var site = this.httpGet('http://moodle.domain.com/user/view.php');
this.userName = site.body.querySelector('div.logininfo a').text;
# To just pull changes from Github, forcing Git to use your local changes for any conflicts:
git pull --strategy=ours origin master
# To completely update each of your Git repositories in one command (run this inside each repository):
git add . && git commit -m "Updating to current working version" && git pull --strategy=ours origin master && git push origin master
@burningTyger
burningTyger / app.rb
Created January 28, 2011 08:07 — forked from lchanmann/app.rb
require 'rubygems'
require 'haml'
require 'sinatra'
require 'sinatra/flash'
require 'file_uploader'
enable :sessions
get '/' do
haml :index
module Sinatra
class Base
def call!(env)
@env = env
@request = Request.new(env)
@response = Response.new
@params = indifferent_params(@request.params)
force_encoding(@params)
module Food
def self.included(model)
model.property :id, Serial
model.property :price, Integer, :min => 0 # builtin validation works just fine
model.property :calories, Integer, :min => 0
model.before(:valid?, :custom_validation)
end
def custom_validation
# stolen from http://github.com/cschneid/irclogger/blob/master/lib/partials.rb
# and made a lot more robust by me
# this implementation uses erb by default. if you want to use any other template mechanism
# then replace `erb` on line 13 and line 17 with `haml` or whatever
module Sinatra::Partials
def partial(template, *args)
template_array = template.to_s.split('/')
template = template_array[0..-2].join('/') + "/_#{template_array[-1]}"
options = args.last.is_a?(Hash) ? args.pop : {}
options.merge!(:layout => false)
require "matrix"
#First, you construct an adjacency matrix. An adjacency matrix is just a matrix of what is linking to what.
#[0, 1, 1, 1, 1, 0, 1]
#[1, 0, 0, 0, 0, 0, 0]
#[1, 1, 0, 0, 0, 0, 0]
#[0, 1, 1, 0, 1, 0, 0]
#[1, 0, 1, 1, 0, 1, 0]
#[1, 0, 0, 0, 1, 0, 0]
@burningTyger
burningTyger / 0_reuse_code.js
Last active August 29, 2015 14:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@burningTyger
burningTyger / README
Last active August 29, 2015 14:18 — forked from rwest/README
These two files should help you to import passwords from mac OS X keychains to 1password.
Assumptions:
1) You have some experience with scripting/are a power-user. These scripts worked for me
but they haven't been extensively tested and if they don't work, you're on your own!
Please read this whole document before starting this process. If any of it seems
incomprehensible/frightening/over your head please do not use these scripts. You will
probably do something Very Bad and I wouldn't want that.
2) You have ruby 1.9.2 installed on your machine. This comes as standard with Lion, previous
versions of OS X may have earlier versions of ruby, which *may* work, but then again, they
<div class="container">
<div class="row">
<div class="col-sm-6 col-md-4 col-md-offset-4">
<h1 class="text-center login-title">Sign in to continue to Bootsnipp</h1>
<div class="account-wall">
<img class="profile-img" src="https://lh5.googleusercontent.com/-b0-k99FZlyE/AAAAAAAAAAI/AAAAAAAAAAA/eu7opA4byxI/photo.jpg?sz=120"
alt="">
<form class="form-signin">
<input type="text" class="form-control" placeholder="Email" required autofocus>
<input type="password" class="form-control" placeholder="Password" required>