Skip to content

Instantly share code, notes, and snippets.

@cevaris
cevaris / survey-to-json-csv.py
Created August 27, 2021 16:07
DRAFT: B2B records dump w/ survey transformation
#!/usr/bin/env python3
import json
import os
import sys
class UserRecord(object):
user_id: str
first_name: str
last_name: str
@cevaris
cevaris / snake_to_hyphen_case.py
Created January 4, 2021 00:53
snake_to_hyphen_case.py
input = 'this_is_a_test_string'
output = ''
for i in range(0, len(input)):
char = input[i]
if char == '_':
output += '-'
else:
output += char
@cevaris
cevaris / data.js
Created November 19, 2020 23:39
custom Prototype iterator
function Data() {
this.data = [1, 2, 3, 4, 5];
}
Data.prototype[Symbol.iterator] = function* () {
for (const e of this.data) {
yield e;
}
};
@cevaris
cevaris / linkList.js
Last active November 4, 2020 14:15
LinkList iterator method
@cevaris
cevaris / timeout.ts
Last active June 3, 2020 21:08
Using Promise.race and setTimeout for timeout logic for Promise execution
export const REPORT_TIMEOUT_MS = 5000;
const TIMEOUT_ERROR = new Error('Ran out of time!!');
const TIMEOUT_PROMISE = new Promise<boolean>(
(_, reject) => setTimeout(() => reject(TIMEOUT_ERROR), REPORT_TIMEOUT_MS)
);
const myPromise = new Promise(...);
const success: boolean = await Promise.race([myPromise, TIMEOUT_PROMISE]);
@cevaris
cevaris / stopwatch.ts
Last active June 3, 2020 21:22
Simple stopwatch that measures overall time.
interface StopwatchResults {
startDate: Date
endDate: Date
latencyMs: number
}
class Stopwatch {
private startDate?: Date
private endDate?: Date
@cevaris
cevaris / gist:426ad6143165d81dea5944cdc6153357
Created February 1, 2018 16:18
Consumer keys of official Twitter clients

Twitter公式クライアントのコンシューマキー

Twitter for iPhone

Consumer key: IQKbtAYlXLripLGPWd0HUA
Consumer secret: GgDYlkSvaPxGxC4X8liwpUoqKwwr3lCADbz8A7ADU

Twitter for Android

Consumer key: 3nVuSoBZnx6U4vzUxf5w
Consumer secret: Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys

Twitter for Google TV

Consumer key: iAtYJ4HpUVfIUoNnif1DA

Multiple MySQL Versions with Homebrew

For homebrew version 0.9.5.

brew -v # => Homebrew 0.9.5

Install the current version of mysql.

# Install current mysql version

brew install mysql

@cevaris
cevaris / .tmux.conf
Created February 8, 2017 17:17
tmux 2.4 conf
set-option -g default-shell /bin/zsh
set-option -g default-command "reattach-to-user-namespace -l zsh"
set -g default-terminal "screen-256color"
set -g base-index 1
# Override default prefix
unbind C-b
set -g prefix C-t
bind C-t send-prefix
@cevaris
cevaris / gtest-install.rst
Created December 18, 2016 17:14 — forked from massenz/gtest-install.rst
Describes how to install and run GTest, a Google framework to conduct unit testing in C++

Build and install Google Test

Download the latest_ (1.7.0) from Google Code (Q: where is it going to live, once GCode shuts down?)

Then follow the primer_, but more to the point, the README (YMMV) Having installed CLion and cmake, this is how I built gtest:

brew install cmake
cd gtest-1.7.0