Skip to content

Instantly share code, notes, and snippets.

@codeniko
codeniko / signapk.sh
Last active February 10, 2019 05:20
sign apk
#!/bin/bash
# Key Vars
keyfile='my-release-key.jks'
# APK Vars
filename="${1%.*}"
ext='.apk'
aligned="$filename-aligned$ext"
signed="$filename-signed$ext"
@codeniko
codeniko / Local PR test and merge.md
Created August 14, 2018 04:39 — forked from adam-p/Local PR test and merge.md
Testing a pull request, then merging locally; and avoiding TOCTOU

It's not immediately obvious how to pull down the code for a PR and test it locally. But it's pretty easy. (This assumes you have a remote for the main repo named upstream.)

Getting the PR code

  1. Make note of the PR number. For example, Rod's latest is PR #37: Psiphon-Labs/psiphon-tunnel-core#37

  2. Fetch the PR's pseudo-branch (or bookmark or rev pointer whatever the word is), and give it a local branch name. Here we'll name it pr37:

$ git fetch upstream pull/37/head:pr37
@codeniko
codeniko / sticky.html
Created June 29, 2018 03:47
Sticky floater example
<html>
<head>
<style>
html, body, div {
margin: 0px;
padding: 0px;
}
.content {
height: 900px;
width: 100%;
@codeniko
codeniko / README.md
Last active April 26, 2018 08:46 — forked from jed/LICENSE.txt
generate random UUIDs

UUID

Returns a random v4 UUID of the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx, where each x is replaced with a random hexadecimal digit from 0 to f, and y is replaced with a random hexadecimal digit from 8 to b.

There's also @LeverOne's approach using iteration, which is one byte shorter.

@codeniko
codeniko / catweight.js
Created November 22, 2017 05:51
Intake calorie calculator for adult neutered cats
#!/usr/local/bin/node
// formula from: https://vet.osu.edu/vmc/companion/our-services/nutrition-support-service/basic-calorie-calculator
const args = process.argv
if (args.length !== 3) {
console.log(`./${__filename} POUNDS`)
return 1
}
@codeniko
codeniko / dl
Created March 29, 2017 04:02
Download rom
#!/bin/bash
zip='.tmp.zip'
curl -L -k -e 'https://www.emuparadise.me' "$1" > "$zip"
unzip "$zip"
rm "$zip
@codeniko
codeniko / gist:c6f7ca9992b938d8d561cb8a7b76ed3b
Created December 8, 2016 22:32 — forked from cdown/gist:1163649
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
@codeniko
codeniko / AsyncController.diff
Created December 1, 2016 01:32 — forked from jriecken/AsyncController.diff
Contextual Logging
import play.api.Logger
import org.slf4j.MDC
+import scala.concurrent.{ExecutionContext, Future}
import java.util.UUID
+import java.util.concurrent.Executors
-object SyncController extends Controller {
- def syncEndpoint(profileId: Long) = Action(parse.json) { req =>
+object AsyncController extends Controller {
+ implicit val ec = ExecutionContext.fromExecutor(Executors.newFixedThreadPool(2))
+ // For this example, ensure the threads in the pool are already created
curl -H "Content-Type: application/json" -d '{"webhook": "https://yourserver.com", "features": {"manuallySendReadReceipts": true, "receiveReadReceipts": true, "receiveDeliveryReceipts": false, "receiveIsTyping": false}}' -u '<BOT_ID>:<API_KEY>' 'https://api.kik.com/v1/config'
@codeniko
codeniko / login.js
Last active July 26, 2017 21:32
login into yahoo and get cookies
var exec = require('child_process').exec;
var when = require('when');
function login(credentials) {
var whenAuthenticated = when.defer();
var user = credentials.user;
var pass = credentials.pass;
var res = {