Skip to content

Instantly share code, notes, and snippets.

@ngarneau
ngarneau / hidden-files.sh
Created November 11, 2011 03:46
Display on/off hidden files on mac osx
#!/bin/bash
# Simple script to show/hide hidden files on macsox using terminal
if [[ $1 != true && $1 != false ]]
then
echo Expected parameters are true or false
exit
else
if [ $1 = true ]; then
echo Showing hidden files...
@ngarneau
ngarneau / hash-loop.rb
Created November 11, 2011 03:53
Ruby - Looping through multidim. hash
- @objects.each do |item|
.feed-item.left.relative
.feed-image.left
- if item['pictures'].empty? == false
- item['pictures'].each do |pics|
- if pics['main'] == true
%img{:src => "#{pics['filename']}-small.png"}
- else
%img{:src => "default-small.png"}
.feed-spec.left
@ngarneau
ngarneau / chat.rb
Created December 14, 2011 18:02 — forked from rkh/chat.rb
Simple Chat Application using the Sinatra Streaming API
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do
@ngarneau
ngarneau / prepare-commit-msg
Created May 15, 2012 22:30
Checks if your commit / branch name as a specific pattern
#!/usr/bin/env ruby
# Get the commit type.
# We only want this hook to take effect on message commit.
commit_type = ARGV[1]
if commit_type != "message"
exit 0
end
# The pattern we are looking
@ngarneau
ngarneau / hackpass.js
Created November 20, 2012 21:17
Hack someone saved password into the browser
document.getElementById('pass').value;
@ngarneau
ngarneau / main.py
Created February 20, 2018 15:20
Pytorch Embedding Issue
import torch
import torch.optim as optim
from torch import autograd
from torch.nn import Module, Embedding, Linear, MSELoss, functional as F
from torch.utils.data import TensorDataset, DataLoader
import random
class IssueModule(Module):
@ngarneau
ngarneau / ccc.json
Created October 20, 2020 20:41
Parsed Version of the Criminal Code of Canada
{
"1": {
"a)": {
"text": "articles 119 ou 120 (corruption de fonctionnaires);"
},
"b)": {
"text": "article 121 (fraudes envers le gouvernement);"
},
"c)": {
"text": "article 123 (actes de corruption dans les affaires municipales);"