Skip to content

Instantly share code, notes, and snippets.

View luveti's full-sized avatar

luveti

  • DRM Productions Inc.
  • Ohio
View GitHub Profile
@luveti
luveti / scanny.js
Created July 10, 2018 21:54
Scans a directory recursively for a string and outputs all the matching lines to a file
#!/usr/bin/env node
const fs = require('fs')
const path = require('path')
async function walkSync(rootDir) {
function readdir(path) {
return new Promise((resolve, reject) => {
fs.readdir(path, (err, files) => err ? reject(err) : resolve(files))
})
@luveti
luveti / walkSync.js
Created July 10, 2018 21:11
Walk Sync - Stack Based
async function walkSync(rootDir) {
const fs = require('fs')
const path = require('path')
function readdir(path) {
return new Promise((resolve, reject) => {
fs.readdir(path, (err, files) => err ? reject(err) : resolve(files))
})
}

Keybase proof

I hereby claim:

  • I am luveti on github.
  • I am luveti (https://keybase.io/luveti) on keybase.
  • I have a public key ASCtbuo8FQmua9-EpsNf8gFCs-o__8WEeMRejJjwWlEbpAo

To claim this, I am signing this object:

@luveti
luveti / promisifyAll.js
Created July 23, 2017 01:01
promisify an entire nodejs module using util.promisify
function promisifyAll(module, callbackParameterName) {
const util = require('util')
function isFunction(f) {
return f && Object.prototype.toString.call(f) === '[object Function]'
}
if (!callbackParameterName) callbackParameterName = 'callback'
Object.keys(module)
@luveti
luveti / installDeps.js
Last active May 17, 2017 20:47
Installs node_modules into temp directory and gives you access to them. This lets you avoid needing a node_modules folder.
function installDeps(deps, quiet, cb) {
const hash = require('crypto').createHash('md5').update(__filename).digest('hex')
const dir = require('os').tmpdir() + require('path').sep + hash
try {
require('fs').mkdirSync(dir)
if (!quiet) console.log(`Created temp folder at "${dir}"`)
} catch (e) {}
try {
require('fs').writeFileSync(dir + require('path').sep + 'package.json', JSON.stringify({
name: hash, description: hash, author: hash, repository: hash, license: "ISC",
@luveti
luveti / ios_img_gen.js
Last active June 10, 2021 22:37
Generate iOS icons and splashscreen images from an svg, using nodejs and phantomjs.
#!/usr/bin/env node
const path = require("path")
const fs = require("fs")
// https://gist.github.com/luveti/67a1c93be3d58b085f6c76ae876c556c
function installDeps(deps, quiet, cb) {
const hash = require('crypto').createHash('md5').update(__filename).digest('hex')
const dir = require('os').tmpdir() + require('path').sep + hash
try {
@luveti
luveti / require.js
Created September 19, 2016 17:12
A simple require function that: takes an array of urls, fetches the code using the Fetch API, then evals them using a wrapper that exposes module.exports to the code.
function require (urls, cb) {
if (!Array.isArray(urls) && typeof urls === 'string') urls = [urls];
var modules = [];
var i = 0, next = function () {
fetch(urls[i])
.then(function (response) {
return response.text();
})
.then(function (code) {
try {
@luveti
luveti / .vimrc
Last active September 8, 2016 16:14
My .vimrc, if anyone's interested :)
" luveti - vimrc - 9/8/16
" these 4 lines are required by Vundle
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" list our plugins, Vundle needs to be the first one
Plugin 'VundleVim/Vundle.vim'
@luveti
luveti / pull_apk_from_android_device.sh
Created June 13, 2016 15:28
Pull APK from android device
# list all packages
adb -dshell pm list packages
# get full apk path
adb -d shell pm path <package name>
# pull it
adb pull <path to apk> <local path>
@luveti
luveti / small_big_recursive.sh
Created June 9, 2016 22:43
Recursively find the smallest and largest file by extension, in a directory
#! /bin/bash
find "$1" -type f -name "*.$2" -printf "%s\t%p\n" | sort -n -r | tail -1;
find "$1" -type f -name "*.$2" -printf "%s\t%p\n" | sort -n | tail -1;