Skip to content

Instantly share code, notes, and snippets.

View limsammy's full-sized avatar

Sam Lim limsammy

View GitHub Profile
import os
import pickle
import warnings
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from tensorflow.keras.callbacks import EarlyStopping
from tensorflow.keras.layers import Dense
from tensorflow.keras.layers import Dropout
@patrickfav
patrickfav / example_jekyll.md
Last active January 7, 2024 19:39
A Liquid Filter for obfuscating an Email Address (can be used with Jekyll aswell).

In Jekyll set a variable for the mail, e.g. in the _config.yml

email: name@mail.com

then use it in your page

Reach me under:	{{ site.email | mailObfuscate }}

which will generate the following HTML

#!/usr/bin/env python3
# Gambling Statistics Problem:
# If you play roulette every day and quit whenever you're ahead by x amount,
# do you make money in the long run?
# Answer:
# No.
import random
STARTING_BALANCE = 100000
@duckythescientist
duckythescientist / tqdm_longrun.py
Created October 9, 2017 14:18
Tqdm wrapper and decorator to give a long-running function a progress bar
#/usr/bin/env python3
import time
import threading
import functools
import tqdm
def long_running_function(*args, **kwargs):
@rwarbelow
rwarbelow / running_app_in_production_locally.markdown
Created November 11, 2015 18:26
How to Run a Rails App in Production Locally
  1. Add gem 'rails_12factor' to your Gemfile. This will add error logging and the ability for your app to serve static assets.
  2. bundle
  3. Run RAILS_ENV=production rake db:create db:migrate db:seed
  4. Run rake secret and copy the output
  5. From the command line: export SECRET_KEY_BASE=output-of-rake-secret
  6. To precompile your assets, run rake assets:precompile. This will create a folder public/assets that contains all of your assets.
  7. Run RAILS_ENV=production rails s and you should see your app.

Remember to clobber your assets (rake assets:clobber) and re-precompile (rake assets:precompile) if you make changes.

Part I: User Creation

  1. add route for new_user_path
  2. create a UsersController with new action
  3. create new.html.erb
  4. generate user model with password_digest string field
  5. uncomment gem 'bcrypt' in Gemfile and add has_secure_password in User model
  6. add create action in UsersController
  7. implement logic for creating a user
  8. set session[:user_id] in create action
@stefan-lz
stefan-lz / youtube-to-mp3.rb
Created June 13, 2012 14:37
youtube vids to mp3 files (ruby)
#!/usr/bin/ruby
#usage: youtube-to-mp3 <youtube-url>
#example: youtube-to-mp3 http://www.youtube.com/playlist?list=PL398CE05652474A1E
#desc: downloads a single youtube vid or a playlist, then converts to mp3.
# Requires youtube-dl and ffmpeg
url = ARGV[0]
system("youtube-dl -citA #{url}")