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 scala.annotation.tailrec | |
object VarLenEncoding extends App { | |
val testData = List(("", ""), ("XYZ", "XYZ"), ("AAABC", "A3BC"), ("XXXX", "X4")) | |
def encode(s: String): String = split(s, Nil).map(f => if (f.length == 1) f else s"${f.head}${f.length}").mkString | |
def decode(s: String): String = ??? | |
@tailrec def split(s: String, acc: List[String]): List[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
package org.aakretech.trekwar2.server.utils; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.io.StringReader; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
import java.net.URLConnection; | |
import java.security.MessageDigest; |
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
Basic | |
===== | |
[Shift]+[Mod]+[Enter] - launch terminal. | |
[Mod]+[b] - show/hide bar. | |
[Mod]+[p] - dmenu for running programs like the x-www-browser. | |
[Mod]+[Enter] - push acive window from stack to master, or pulls last used window from stack onto master. | |
[Mod] + [j / k] - focus on next/previous window in current tag. |
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
// ==UserScript== | |
// @name Get emails from hunter.io search result page | |
// @namespace http://frostvoid.com | |
// @version 1.0 | |
// @match https://hunter.io/search* | |
// @grant GM_registerMenuCommand | |
// @require http://code.jquery.com/jquery-latest.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; |
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
<html ng-app> | |
<body> | |
<div class="container">Enter your memorable word: <input type="text" ng-model="memword"/></div> | |
<div class="container"> | |
<h5>memorable word character list</h5> | |
<span ng-repeat="c in memword track by $index">{{$index+1}} - {{c}}<br/></span> | |
</div> |
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
trait RecursiveFileFindBehaviour { | |
import java.io.File | |
/** | |
* Recursively finds all the files in the file system under a given directory | |
* | |
* @param dir the directory to find all files in | |
* @param filesFound always use Set.empty when calling, used internally for keeping track of discovered files | |
* @return A set of files from the specified directory and all subdirectories found in tree | |
*/ | |
def findFiles(dir: File, filesFound: Set[File] = Set.empty): Set[File] = { |
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
// ==UserScript== | |
// @name Bitbucket hide outdated comments | |
// @namespace http://frostvoid.com | |
// @version 1.0 | |
// @match http://your-bitbucket.com:8080/* | |
// @require http://code.jquery.com/jquery-latest.js | |
// ==/UserScript== | |
/* jshint -W097 */ | |
(function() { |
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
// --------------------- arguments -------------------- | |
var objectID = ObjectId("53623ef33004e212edccab08"); // Change this | |
var findMultiple = true; | |
// ----------------------- code ----------------------- | |
var stack = []; | |
db.getCollectionNames().forEach(function (collName) { | |
var docs = db.getCollection(collName).find(); | |
docs.forEach(function (doc) { | |
doc._FROM = collName; |
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 | |
# --------------------------- Settings ------------------------- | |
gitUsername="erlendaakre" | |
# ----------------------------- Code --------------------------- | |
echo "Getting list of all public repositories for user $gitUsername" | |
array=($(curl -s 1 https://api.github.com/users/$gitUsername/repos | grep '\"name\"\|clone' | sed 's/.*: \"//' | sed 's/\",$//' | xargs echo)) | |
arrayLength=${#array[@]} | |
reposFound=$(($arrayLength/2)) | |
i=0 |