Skip to content

Instantly share code, notes, and snippets.

View ilyazub's full-sized avatar
🇺🇦

ilyazub

🇺🇦
View GitHub Profile
def countChange(money: Int, coins: List[Int]): Int =
if (money < 0 || coins.isEmpty)
0
else if (money == 0)
1
else
countChange(money - coins.head, coins) + countChange(money, coins.tail)
@timols
timols / ruby_haversine.rb
Created March 29, 2013 01:15
Ruby implementation of the haversine distance formula
##
# Haversine Distance Calculation
#
# Accepts two coordinates in the form
# of a tuple. I.e.
# geo_a Array(Num, Num)
# geo_b Array(Num, Num)
# miles Boolean
#
# Returns the distance between these two
@Ajedi32
Ajedi32 / .bashrc
Created May 1, 2013 16:15
Add this to your `~/.bashrc` file to enable the use of the `subl` command on your Git Bash prompt on Windows. (It may work with other shells as well, but I've only tested this with Git Bash on Windows and bash on Ubuntu.) Note that this command not only supports file input, but also simulates support for piped input as well. ``` Usage: subl file…
# Enable the use of the `subl` command
subl () {
subl_path='C:\Program Files\Sublime Text 2\sublime_text.exe'
if test -t 0
then
"$subl_path" $*
else
timestamp=`date +%s`
filename=$1
shift
@willurd
willurd / web-servers.md
Last active April 28, 2024 21:38
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@JamesDullaghan
JamesDullaghan / digitalocean.md
Created July 6, 2013 20:54
Deploy rails app to digitalocean with nginx, unicorn, capistrano & postgres

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email

@speric
speric / poodir-notes.md
Last active January 24, 2024 10:31
Notes From "Practical Object-Oriented Design In Ruby" by Sandi Metz

Chapter 1 - Object Oriented Design

The purpose of design is to allow you to do design later, and it's primary goal is to reduce the cost of change.

SOLID Design:

  • Single Responsibility Principle: a class should have only a single responsibility
  • Open-Closed Principle: Software entities should be open for extension, but closed for modification (inherit instead of modifying existing classes).
  • Liskov Substitution: Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.
  • Interface Segregation: Many client-specific interfaces are better than one general-purpose interface.
@arusahni
arusahni / nocache.py
Last active December 28, 2022 13:12
Flask nocache decorator
from flask import make_response
from functools import wraps, update_wrapper
from datetime import datetime
def nocache(view):
@wraps(view)
def no_cache(*args, **kwargs):
response = make_response(view(*args, **kwargs))
response.headers['Last-Modified'] = datetime.now()
response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0'
@calebwoods
calebwoods / nginx.conf
Created May 10, 2014 20:18
Sample Nginx config for deployment of Angular.js app
server { listen 80;
server_name example.com;
access_log /var/log/example.com/nginx.access.log;
error_log /var/log/example.com/nginx.error.log;
root /var/www/apps/example.com/public;
charset utf-8;
location / {
rewrite ^ https://$host$request_uri? permanent;
}
@staltz
staltz / introrx.md
Last active May 2, 2024 12:31
The introduction to Reactive Programming you've been missing
@mgreensmith
mgreensmith / Slack_solarized_themes
Last active May 2, 2024 18:14
Solarized themes for Slack
Solarized
#FDF6E3,#EEE8D5,#93A1A1,#FDF6E3,#EEE8D5,#657B83,#2AA198,#DC322F
Solarized Dark
#073642,#002B36,#B58900,#FDF6E3,#CB4B16,#FDF6E3,#2AA198,#DC322F