Skip to content

Instantly share code, notes, and snippets.

Avatar

Sina Meraji sinameraji

View GitHub Profile
@leon-sleepinglion
leon-sleepinglion / compound_interest_calculator.py
Created Mar 16, 2018
Coding for Economist Minds - Week 1
View compound_interest_calculator.py
#-------------------------------------------------------------------
# This is a compound interest calculator, along with some challenge
# Written by Leon Wee, March 2018.
# Anyone may freely copy or modify this program.
#-------------------------------------------------------------------
# C = P[(1+r)^n - 1]
# Where:
# C = the compound interest
# P = the principal investment amount (the initial deposit or loan amount)
@spacemonkey
spacemonkey / .gitignore
Created Jul 11, 2014
.gitignore for Hexo powered websites
View .gitignore
.DS_Store
Thumbs.db
db.json
debug.log
node_modules/
public/
.deploy/
themes/
@aheinze
aheinze / gist:02db57da725cf7ba4047
Last active Oct 24, 2019
letterAvatar - create Letter avatar based on name initials
View gist:02db57da725cf7ba4047
/*
* LetterAvatar
*
* Create Letter avatar based on Initials -
* based on https://gist.github.com/leecrossley/6027780
*/
(function(w, d){
function LetterAvatar (name, size) {
@cspickert
cspickert / GoogleSpreadsheets.py
Created Jan 20, 2012
Export a Google Spreadsheet using python.
View GoogleSpreadsheets.py
#!/usr/bin/python
import re, urllib, urllib2
class Spreadsheet(object):
def __init__(self, key):
super(Spreadsheet, self).__init__()
self.key = key
class Client(object):
View maktabkhooneh.js
// https://maktabkhooneh.org/course/%D9%85%D8%A8%D8%A7%D9%86%DB%8C-%D8%A7%D9%82%D8%AA%D8%B5%D8%A7%D8%AF-mk170/
[...document.querySelectorAll('a.chapter__unit')]
.map(x => () => fetch(x.href)
.then(x => x.text())
.then(x => new DOMParser().parseFromString(x, 'text/html').querySelector('meta[property="og:video"]').content)
.then(y => console.log(y, x.children[1].innerText.trim().replace(/\s/g, '_') + '.mp4'))
)
.reduce((promise, next) => promise.then(next), Promise.resolve())
.then(() => console.log('Finished!'));
@ken47
ken47 / gist:3870213
Created Oct 11, 2012
single-layer perceptron in Octave / Matlab
View gist:3870213
function perceptron0 = perceptron(numPoints, runs)
iters = 0;
for i = 1:runs
errors = 2;
points = genPoints(numPoints);
gWeights = [0 0 0];
[fWeights,a,b] = genTarget;
while errors > 0
errors = 0;
View install-ebook-convert.md

Install cask that extends the brew command :

brew install phinze/cask/brew-cask

Install calibre using cask :

brew cask install calibre
@yjzhang
yjzhang / k_means.py
Last active Jul 6, 2020
basic python implementation of k-means and online k-means clustering
View k_means.py
# Online k-means algorithm
# see http://www.cs.princeton.edu/courses/archive/fall08/cos436/Duda/C/sk_means.htm
import numpy as np
def k_means(data, k, threshhold=2):
"""
Does k-means clustering of the data.
Args:
@andphe
andphe / gist:3232343
Created Aug 2, 2012
Export your links from Safari reading list
View gist:3232343
/usr/bin/plutil -convert xml1 -o - ~/Library/Safari/Bookmarks.plist | grep -E -o '<string>http[s]{0,1}://.*</string>' | grep -v icloud | sed -E 's/<\/{0,1}string>//g'
You can’t perform that action at this time.