This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/csv" | |
"net/http" | |
"html/template" | |
"fmt" | |
"strconv" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
fileprivate protocol Statelike { | |
var stateMachine: StateMachine { get } | |
func logIn() | |
func logOut() | |
} | |
extension Statelike { | |
func logIn() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#read more at http://alimoeenysbrain.blogspot.com/2013/10/automatic-versioning-with-git-commit.html | |
#replace all MYPROJECT with your project name | |
#for languages other than go (golang) replace all the .go extensions with your language extensions and modify BODY to reflect you language syntax | |
VERBASE=$(git rev-parse --verify HEAD | cut -c 1-7) | |
echo $VERBASE | |
NUMVER=$(awk '{printf("%s", $0); next}' MYPROJECTversion.go | sed 's/.*MYPROJECT\.//' | sed 's/\..*//') | |
echo "old version: $NUMVER" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"price": "USD 4.99", | |
"dollars": "4.99", | |
"country": "Algeria", | |
"countryCode": "DZA", | |
"link": "https://www.spotify.com/dz-fr/premium/", | |
"percentageOfUSA": 49, | |
"discount": 51 | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python3 | |
# Largely copied from http://www.mathewinkson.com/2015/03/delete-old-tweets-selectively-using-python-and-tweepy | |
# However, Mathew's script cannot delete tweets older than something like a year (these tweets are not available from the twitter API) | |
# This script is a complement on first use, to delete old tweets. It uses your twitter archive to find tweets' ids to delete | |
# How to use it : | |
# - download and extract your twitter archive (tweet.js will contain all your tweets with dates and ids) | |
# - put this script in the extracted directory | |
# - complete the secrets to access twitter's API on your behalf and, possibly, modify days_to_keep | |
# - delete the few junk characters at the beginning of tweet.js, until the first '[' (it crashed my json parser) | |
# - review the script !!!! It has not been thoroughly tested, it may have some unexpected behaviors... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on http://www.gamasutra.com/blogs/ChrisSimpson/20140717/221339/Behavior_trees_for_AI_How_they_work.php | |
public enum NodeStatus | |
{ | |
Success, Failure, Running | |
} | |
public interface IBehaviorNode | |
{ | |
NodeStatus Execute(Entity entity); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gensim.models import Word2Vec | |
# Load pretrained model (since intermediate data is not included, the model cannot be refined with additional data) | |
model = Word2Vec.load_word2vec_format('GoogleNews-vectors-negative300.bin', binary=True, norm_only=True) | |
dog = model['dog'] | |
print(dog.shape) | |
print(dog[:10]) | |
# Deal with an out of dictionary word: Михаил (Michail) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
M[16],X=16,W,k;main(){T(system("stty cbreak") | |
);puts(W&1?"WIN":"LOSE");}K[]={2,3,1};s(f,d,i | |
,j,l,P){for(i=4;i--;)for(j=k=l=0;k<4;)j<4?P=M | |
[w(d,i,j++)],W|=P>>11,l*P&&(f?M[w(d,i,k)]=l<< | |
(l==P):0,k++),l=l?P?l-P?P:0:l:P:(f?M[w(d,i,k) | |
]=l:0,++k,W|=2*!l,l=0);}w(d,i,j){return d?w(d | |
-1,j,3-i):4*i+j;}T(i){for(i=X+rand()%X;M[i%X] | |
*i;i--);i?M[i%X]=2<<rand()%2:0;for(W=i=0;i<4; | |
)s(0,i++);for(i=X,puts("\e[2J\e[H");i--;i%4|| | |
puts(""))printf(M[i]?"%4d|":" |",M[i]);W-2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adapted from Stack Overflow answer by David Crow http://stackoverflow.com/a/43235 | |
// Question: Algorithm to randomly generate an aesthetically-pleasing color palette by Brian Gianforcaro | |
// Method randomly generates a pastel color, and optionally mixes it with another color | |
func generateRandomPastelColor(withMixedColor mixColor: UIColor?) -> UIColor { | |
// Randomly generate number in closure | |
let randomColorGenerator = { ()-> CGFloat in | |
CGFloat(arc4random() % 256 ) / 256 | |
} | |
var red: CGFloat = randomColorGenerator() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// SendEmailWithAttachment | |
// | |
// Created by Kelly Egan on 3/17/15. | |
// Copyright (c) 2015 Kelly Egan. All rights reserved. | |
// | |
import UIKit | |
import MessageUI |
OlderNewer