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
ngarneau / main.py
Created Feb 20, 2018
Pytorch Embedding Issue
View main.py
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 / hackpass.js
Created Nov 20, 2012
Hack someone saved password into the browser
View hackpass.js
document.getElementById('pass').value;
@ngarneau
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
end
# The pattern we are looking
@ngarneau
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/, '') }
end
get '/stream', provides: 'text/event-stream' do
@ngarneau
ngarneau / hash-loop.rb
Created Nov 11, 2011
Ruby - Looping through multidim. hash
View hash-loop.rb
- @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 / hidden-files.sh
Created Nov 11, 2011
Display on/off hidden files on mac osx
View hidden-files.sh
#!/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...
You can’t perform that action at this time.