Skip to content

Instantly share code, notes, and snippets.

@Kirill89
Kirill89 / .sh
Last active March 19, 2019 11:41
edit64 - base64 editor. Usage: copy base64 encoded text -> run edit64 in your terminal -> paste updated base64 string
# put it into your ~/.zshrc
edit64()
{
DECODED=$(pbpaste | base64 --decode)
TMP=$(mktemp)
echo "Temporary file: $TMP"
echo "$DECODED" > "$TMP"
vi "$TMP"
UPDATED=$(cat ${TMP})
@Kirill89
Kirill89 / jsts.sh
Last active January 3, 2019 20:50
Convert JavaScript to TypeScript
#!/usr/bin/env bash
if ! [[ -x "$(command -v lebab)" ]]; then
echo 'Error: lebab is not installed.' >&2
echo 'Please run: npm install -g lebab tslint' >&2
exit 1
fi
if ! [[ -x "$(command -v tslint)" ]]; then
echo 'Error: tslint is not installed.' >&2
@Kirill89
Kirill89 / e.js
Last active March 24, 2020 22:33
Custom error in JS
class GoodError extends Error {
constructor(...args) {
super(...args);
this.name = 'GoodError';
Error.captureStackTrace(this, GoodError);
}
}
@Kirill89
Kirill89 / client.js
Created August 13, 2018 06:55 — forked from steinwaywhw/client.js
A minimal term.js server/client demo. To be used with node.js
var client = {};
client.run = function (options) {
options = options || {};
var socket = io.connect(options.remote || "http://localhost:8080");
socket.on('connect', function() {
var term = new Terminal({
@Kirill89
Kirill89 / get_ip.js
Created July 26, 2018 07:45
nodejs get local IP address
const os = require('os');
function getLocalIP() {
for (const ifaces of Object.values(os.networkInterfaces())) {
for (const iface of ifaces) {
if (iface.family === 'IPv4' && iface.internal === false) {
return iface.address;
}
}
}
--log_gc (Log heap samples on garbage collection for the hp2ps tool.)
type: bool default: false
--expose_gc (expose gc extension)
type: bool default: false
--max_new_space_size (max size of the new generation (in kBytes))
type: int default: 0
--max_old_space_size (max size of the old generation (in Mbytes))
type: int default: 0
--max_executable_size (max size of executable memory (in Mbytes))
type: int default: 0
@Kirill89
Kirill89 / dtrace.md
Last active July 10, 2018 06:42
node flamegraph on mac
@Kirill89
Kirill89 / realm.sh
Last active May 2, 2020 10:40
This is a script to easily download realm database file from device and open it in realm browser app.
#!/bin/sh
PACKAGE_NAME="com.trax.retailexecution"
DB_NAME="$1"
OUT_DIR="$HOME/RealmDatabases"
# Check args
if [ -z "$DB_NAME" ]
then
echo "usage ./realm.sh database_name"
@Kirill89
Kirill89 / nodenodenode.js
Created May 27, 2018 14:06
colorful output from webpack to html stream
'use strict';
const {spawn} = require('child_process');
const Convert = require('ansi-to-html');
const express = require('express');
const app = express();
const convert = new Convert({
fg: '#000',
newline: true,
escapeXML: true
@Kirill89
Kirill89 / meltdown.c
Created February 7, 2018 17:21
Minimal meltdown proof of concept with comments and interesting links. [in progress]
// http://board.issociate.de/thread/508268/prockallsyms.html
// sudo grep ' D ' /proc/kallsyms
// g++ meltdown.c -std=c++11 && ./a.out ffffffff81d18564 9
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <ctype.h>
#include <math.h>
#include <sched.h>