Skip to content

Instantly share code, notes, and snippets.

Nicolas ngarneau

Block or report user

Report or block ngarneau

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
ngarneau /
Created Feb 20, 2018
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 import TensorDataset, DataLoader
import random
class IssueModule(Module):
ngarneau / hackpass.js
Created Nov 20, 2012
Hack someone saved password into the browser
View hackpass.js
ngarneau / prepare-commit-msg
Created May 15, 2012
Checks if your commit / branch name as a specific pattern
View prepare-commit-msg
#!/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
# The pattern we are looking
ngarneau / chat.rb
Created Dec 14, 2011 — forked from rkh/chat.rb
Simple Chat Application using the Sinatra Streaming API
View chat.rb
# 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/, '') }
get '/stream', provides: 'text/event-stream' do
ngarneau / hash-loop.rb
Created Nov 11, 2011
Ruby - Looping through multidim. hash
View hash-loop.rb
- @objects.each do |item|
- 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"}
ngarneau /
Created Nov 11, 2011
Display on/off hidden files on mac osx
# Simple script to show/hide hidden files on macsox using terminal
if [[ $1 != true && $1 != false ]]
echo Expected parameters are true or false
if [ $1 = true ]; then
echo Showing hidden files...
You can’t perform that action at this time.