Skip to content

Instantly share code, notes, and snippets.

vaz vaz

Block or report user

Report or block vaz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@vaz
vaz / js-function-declarations.js
Created Oct 16, 2012
Javascript function declaration tutorial
View js-function-declarations.js
> // There are two different ways to define functions in javascript.
> // Functions can be named, or anonymous.
> // The named function syntax looks more like a C- or Java-style "statement":
> function f(){ }
undefined
> // Notice it evaluates to "undefined". I'll come back to this in a sec.
> // The named function syntax binds the function to a local variable with the given name.
> f
[Function: f]
> // It also actually names the function object:
@vaz
vaz / vaz-sorting.cpp
Created Oct 18, 2012
Timed trials of selection, merge and quick sort.
View vaz-sorting.cpp
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <cmath>
using namespace std;
typedef void (*sorting_fun)(int[], int);
@vaz
vaz / closures-tut.js
Last active Dec 14, 2015
Some example and semi-pseudo tutorial code showing using closures for chaining animations.
View closures-tut.js
// the self-calling function is a
// Javascript "module" pattern for
// not leaking stuff into global scope:
(function(){
// simple closure example
function loglater(message){
return function logger(){
console.log(message); // references outer function's argument
@vaz
vaz / euler-primes.rb
Created Sep 1, 2014
Euler problem, prime factorization
View euler-primes.rb
# find primes up to n
def sieve(n)
return n if n == 2
s = (3..n).step(2).to_a
s.each { |i| s.reject! { |j| j != i && j % i == 0 } }
end
def new_sieve(n)
(s = maybe_primes(n)).each { |i| s.reject! { |j| j != i && j % i == 0 } }
@vaz
vaz / SassMeister-input.scss
Created Feb 16, 2015
Generated by SassMeister.com.
View SassMeister-input.scss
// ----
// Sass (v3.4.12)
// Compass (v1.0.3)
// ----
// RANGES
// We use these functions to define ranges for various things, like media queries.
@function lower-bound($range){
@if length($range) <= 0 {
@return 0;
@vaz
vaz / show-all-files-in-finder.sh
Created Dec 23, 2015
Bash script to toggle showing hidden files in Finder
View show-all-files-in-finder.sh
showAllFiles ()
{
local new old=`defaults read com.apple.finder AppleShowAllFiles`;
if [ "$old" = "TRUE" ]; then
new="FALSE";
else
new="TRUE";
fi;
defaults write com.apple.finder AppleShowAllFiles $new;
echo -n "com.apple.finder AppleShowAllFiles = ";
@vaz
vaz / bash-log.txt
Created Apr 22, 2016
testing old-darwin-fallback branch of Listen (PR)
View bash-log.txt
$ bash test.sh
This is what happens now. Simple Gemfile:
source 'https://rubygems.org'
gem 'listen'
Updating bundle...
Fetching gem metadata from https://rubygems.org/............
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
@vaz
vaz / 1 - Intro to HTTP - Lecture Notes.md
Last active May 16, 2016
intro-to-http (Van-Web-Apr25) [2016-05-16]
View 1 - Intro to HTTP - Lecture Notes.md

Intro to HTTP

Here are the lecture notes from May 16, 2016: Intro to HTTP

What is HTTP

HTTP is Hyper-Text Transfer Protocol.

OK, What is Hyper-Text?

@vaz
vaz / sinatra-sessions.rb
Created May 16, 2016
Sinatra sessions example
View sinatra-sessions.rb
# basic sinatra app showing some use of sessions to handle
# some (insecure) authentication
require 'sinatra'
# enable default sessions support
# sessions are "like hashes" and get serialized (stringified) and
# stored directly in a session cookie.
# Sinatra (actually a Rack sessions extension) handles this for you
enable :sessions
@vaz
vaz / 1-README.md
Last active Jun 23, 2016
Lighthouse Labs - Breakout on Acceptance Testing with Capybara (2016-05-18)
View 1-README.md

Acceptance Testing

2016-05-18 breakout by Vaz

This breakout covered:

  • Using RACK_ENV in the conventional way to use a different db for development than for tests
  • Adding RSpec to the skeleton with a (very) basic model spec
  • Introduction to acceptance testing and Capybara, focusing on form submission for creating new records
You can’t perform that action at this time.