Skip to content

Instantly share code, notes, and snippets.

@vsetka
vsetka / setup-kitkat.sh
Last active January 26, 2019 16:35
Android Emulator Setup (using cli sdk tools only)
sdkmanager "system-images;android-19;google_apis;x86"
avdmanager create avd -n Emulator-Api19-Google -k "system-images;android-19;google_apis;x86"
# select no custom hardware profile and then run the emulator from the /tools directory within the android-sdk dir
./emulator -avd Emulator-Api19-Google
@vsetka
vsetka / get-cookie-setter.js
Created May 18, 2018 11:12
Prints the caller function from which a cookie is set
@vsetka
vsetka / summarize_github_stats.js
Last active November 20, 2017 14:09
Summarizes repo language stats for top 100 (by star count) user owned repos to get a "feel" for user language preference/experience. Replace GITHUB_USERNAME with a user you want to summarize and YOUR_GITHUB_API_TOKEN with the access token (https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/)
"use strict";
const https = require("https");
const API_TOKEN = "YOUR_GITHUB_API_TOKEN";
const GITHUB_USER = "GITHUB_USERNAME";
const request = (options, postBody) => {
return new Promise((resolve, reject) => {
const req = https.request(options, res => {
let body = "";
case class City(
id: Int,
name: String,
iata: Option[String],
longitude: Option[Double],
latitude: Option[Double],
updatedTimestamp: Long)
object udfHelpers {
val toTimestamp = udf((date: String) => new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(date).getTime)
@vsetka
vsetka / multipart-streaming-s3-upload.js
Created October 19, 2017 11:58
Demonstrates how a file can be read as a stream (from network), piped through gzip and into an s3 bucket without having to store it locally our load it whole in memory
const { Writable, Readable, PassThrough } = require("stream");
const { inherits } = require("util");
const AWS = require("aws-sdk");
const zlib = require("zlib");
const https = require("https");
const gzip = zlib.createGzip();
const s3 = new AWS.S3();
// Change the bucket name to point to an S3 bucket write-able within the IAM role assigned to your Lambda
# Set KeepAlive and RunAtLoad to false
vi ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
# Unload plist
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
# Stop the service if needed
pg_ctl -D /Users/my.username/usr/local/var/postgres/ stop -m fast
@vsetka
vsetka / DisplayDeviceHelper.cpp
Last active November 6, 2017 11:54
Get the Display device info (physical monitor size) from SetupAPI EDID
#include "DisplayDeviceHelper.h"
#include <sstream>
std::string ws2s(const std::wstring& s)
{
int len;
int slength = (int)s.length() + 1;
len = WideCharToMultiByte(CP_ACP, 0, s.c_str(), slength, 0, 0, 0, 0);
char* buf = new char[len];
WideCharToMultiByte(CP_ACP, 0, s.c_str(), slength, buf, len, 0, 0);
@vsetka
vsetka / Cleanup.h
Last active February 23, 2024 07:32
Self deleting executable - Windows
#ifndef CLEANUP_H
#define CLEANUP_H
#include <windows.h>
#include <tchar.h>
#include <string>
#include <iostream>
#include <conio.h>
#endif