Skip to content

Instantly share code, notes, and snippets.

View jonataswalker's full-sized avatar
💭
I may be slow to respond.

Jonatas Walker jonataswalker

💭
I may be slow to respond.
View GitHub Profile
@jonataswalker
jonataswalker / build-tree-from-directory.php
Last active April 2, 2024 18:40
Build a tree (array or json) from any directory.
<?php
**
* Public Domain.
* @author Jonatas Walker
* Based in: http://kvz.io/blog/2007/10/03/convert-anything-to-tree-structures-in-php/
* Usage:
* $root = '/home/www/';
* $allow_ext = array('jpg','gif');
* $exclude_dir = array('tilemill');
* $prefix = 'small';
@jonataswalker
jonataswalker / codility_solutions.txt
Created May 21, 2016 10:11 — forked from lalkmim/codility_solutions.txt
Codility Solutions in JavaScript
Lesson 1 - Iterations
- BinaryGap - https://codility.com/demo/results/trainingU2FQPQ-7Y4/
Lesson 2 - Arrays
- OddOccurrencesInArray - https://codility.com/demo/results/trainingFN5RVT-XQ4/
- CyclicRotation - https://codility.com/demo/results/trainingSH2W5R-RP5/
Lesson 3 - Time Complexity
- FrogJmp - https://codility.com/demo/results/training6KKWUD-BXJ/
- PermMissingElem - https://codility.com/demo/results/training58W4YJ-VHA/
@jonataswalker
jonataswalker / electron-sqlite3.md
Created January 20, 2017 11:53 — forked from craigvantonder/electron-sqlite3.md
Electron SQLite3 Integration

Electron SQLite3 Integration

When trying to use the node-sqlite3 module in Electron I got the error:

Error: Cannot find module '/path/to/my/application/node_modules/sqlite3/lib/binding/electron-v1.4-linux-x64/node_sqlite3.node'

Using Ubuntu 16.04 with Node 7.1.0 and Electron 1.4.12.

I read the following:

#Inject javascript into HTML pages from console

An easy way to inject Javascripts into the current loaded dom using the developer console in chrome.

jQuery

var script = document.createElement('script');
script.src = 'http://code.jquery.com/jquery-1.7.2.min.js';
@jonataswalker
jonataswalker / encryption.js
Created May 1, 2020 20:46 — forked from vlucas/encryption.js
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);

Oh my zsh.

Install with curl

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Enabling Plugins (zsh-autosuggestions & zsh-syntax-highlighting)

  • Download zsh-autosuggestions by
@jonataswalker
jonataswalker / my-mailer.js
Last active February 16, 2020 07:25
Sending mail with Gmail (XOAuth2) and Nodemailer
'use strict';
var xoauth2 = require('xoauth2');
var nodemailer = require('nodemailer');
var smtp = require('nodemailer-smtp-transport');
var htmlToText = require('nodemailer-html-to-text').htmlToText;
// Sending mail with Gmail using XOAuth2
// http://masashi-k.blogspot.com.br/2013/06/sending-mail-with-gmail-using-xoauth2.html
@jonataswalker
jonataswalker / nginx.conf
Created April 13, 2017 12:05 — forked from utahta/nginx.conf
nginx + php-fpm + reverse proxy
user nginx;
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@jonataswalker
jonataswalker / emulator-install-using-avdmanager.md
Created October 7, 2019 20:39 — forked from mrk-han/emulator-install-using-avdmanager.md
Installing and creating Emulators with AVDMANAGER (For Continuous Integration Server or Local Use)

Install and Create Emulators using AVDMANAGER and SDKMANAGER

About

  • The goal of this gist is to quickly pre-install a range of system images to provide our project teams the ability to run emulators on a range of API levels, from API 19 to API 28.
    • These can be run locally or on the base build agent.
  • Note: X86 is the fastest architecture for emulators, though x86_64 would probably be better to test against because most phones are 64 bit now.
  • We create two sets of emulators here, one set with pixel hardware emulation and one set with default oem emulation.

See: Google Documentation on Start the emulator from the command line for more info

@jonataswalker
jonataswalker / sed cheatsheet
Created August 1, 2019 16:54 — forked from un33k/sed cheatsheet
magic of sed -- find and replace "text" in a string or a file
FILE SPACING:
# double space a file
sed G
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
sed '/^$/d;G'