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
{ | |
"cmd": ["babel-node", "$file"], | |
"selector": "source.js", | |
"path": "/usr/local/bin:$PATH", // ENV setting for mac users | |
"quiet": true // get rid of annoying `[Finished in %fs]` | |
} |
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 | |
public extension Array { | |
public func randomItem() -> Element? { | |
guard self.count > 0 else { | |
return nil | |
} | |
let index = Int(arc4random_uniform(UInt32(self.count))) |
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 json | |
capitals = json.load(open('capital.json')) | |
currency = json.load(open('currency.json')) | |
iso3 = json.load(open('iso3.json')) | |
names = json.load(open('names.json')) | |
phone = json.load(open('phone.json')) | |
countries = {} |
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 com.sabrelabs.twitter.auth | |
import scala.collection.BitSet | |
import scala.annotation.tailrec | |
import scala.runtime.RichInt | |
import scala.collection.mutable.ListBuffer | |
object PercentEncoder { | |
def encodeRFC3986(str: String): String = { |
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
class NumberToWordConverter { | |
private val specialNames = arrayOf("", " thousand", " million", " billion", " trillion", " quadrillion", " quintillion") | |
private val tensNames = arrayOf("", " ten", " twenty", " thirty", " forty", " fifty", " sixty", " seventy", " eighty", " ninety") | |
private val numNames = arrayOf("", " one", " two", " three", " four", " five", " six", " seven", " eight", " nine", " ten", " eleven", " twelve", " thirteen", " fourteen", " fifteen", " sixteen", " seventeen", " eighteen", " nineteen") | |
private fun convertLessThanOneThousand(number: Int): String { | |
var number = number | |
var current: String |
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/bash | |
brew_command=/usr/local/bin/brew | |
brew_cask_command="$brew_command cask" | |
echo '#!/bin/bash' | |
echo '' | |
echo 'trap ctrl_c INT' | |
echo 'function ctrl_c() {' | |
echo 'echo "** Trapped CTRL-C"' |
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
//remove old unused containers | |
docker rm -f $(docker ps -a -q) | |
// remove untagged images | |
docker rmi $(docker images | grep "^<none>" | awk '{print $3}') |
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
: \d+:0;(gd|gst|gaa|ga|gc|irb|git reset|git stash|newzsh|glg|gb|git push|git init|grm|gl|mc|top|git rebase|ember|rake|rackup|git rm|sensors|rails s|tree|ls|ember install|rubocop|reboot|pry|gitg|gitk|man|unity|bower install|npm install|bundle install|bundle update|git pull|node|jekyll|kill|bin\/console|tmux|la|cd ~/code|nvm|fm|ruby).*\n |
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
protected boolean fieldWasChanged(String fieldName, IssueEvent issueEvent, String fieldValue) throws GenericEntityException { | |
boolean result = false; | |
List<GenericValue> changeItemList = issueEvent.getChangeLog().getRelated("ChildChangeItem"); | |
Iterator<GenericValue> changeItemListIterator = changeItemList.iterator(); | |
while (changeItemListIterator.hasNext()) { | |
GenericValue changeItem = (GenericValue) changeItemListIterator.next(); | |
String currentFieldName = changeItem.get("field").toString(); | |
if (currentFieldName.equals(fieldName)) // Name of custom field. |
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 csv | |
import json | |
csvfile = open('test.csv', 'r') | |
jsonfile = open('file.json', 'w') | |
def lookahead(iterable): | |
"""Pass through all values from the given iterable, augmented by the | |
information if there are more values to come after the current one | |
(True), or if it is the last value (False). |