Skip to content

Instantly share code, notes, and snippets.

View natchiketa's full-sized avatar

Sara Lara natchiketa

View GitHub Profile
@natchiketa
natchiketa / set-env.ts
Last active June 14, 2023 12:35
Use system environment variables to generate Angular CLI environment files. Uses yargs and dotenv
import { writeFile } from 'fs';
import { argv } from 'yargs';
// This is good for local dev environments, when it's better to
// store a projects environment variables in a .gitignore'd file
require('dotenv').config();
// Would be passed to script like this:
// `ts-node set-env.ts --environment=dev`
// we get it from yargs's argv object
@natchiketa
natchiketa / a Super-simple Nginx reverse proxy with Homebrew on OS X.md
Last active May 18, 2023 04:54
Super-simple Nginx reverse proxy with Homebrew on OS X

Installation

1)

brew install nginx
sudo cp /usr/local/Cellar/nginx/1.8.0/homebrew.mxcl.nginx.plist /Library/LaunchAgents

2)

Replace /usr/local/etc/nginx/nginx.conf with the nginx.conf in this gist. I'm using port 5000 for my current project. Obviously, change server_name as well, and probably the name of its access log.

@natchiketa
natchiketa / passgen.js
Created June 25, 2020 07:34
generate strong password in js
var specials = '!@#$%^&*()_+{}:"<>?\|[];\',./`~';
var lowercase = 'abcdefghijklmnopqrstuvwxyz';
var uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var numbers = '0123456789';
var all = specials + lowercase + uppercase + numbers;
String.prototype.pick = function(min, max) {
var n, chars = '';
@natchiketa
natchiketa / nordls
Last active January 14, 2019 22:39
Ruby script to find the nearest ~50 NordVPN servers with a low load. Requires (free) API key from ipstack.com
#!/usr/bin/env ruby
require 'net/http'
require 'json'
# SET THIS TO YOUR LOCATION (an easy way is to go to maps.google.com and click the map and copy
# paste from the new URL)
MY_LATLNG = [ YOUR_LAT, YOUR_LONG ]
# GET A FREE API KEY FROM ipstack.com
IPSTACK_API_KEY = 'YOUR_IPSTACK_API_KEY'
@natchiketa
natchiketa / GIF-Screencast-OSX.md
Last active August 15, 2018 19:08 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@natchiketa
natchiketa / yo-completion.sh
Last active May 25, 2018 20:47
Bash completion for Yeoman generators
# Bash completion for Yeoman generators - tested in Ubuntu, OS X and Windows (using Git bash)
function _yo_generator_complete_() {
# local node_modules if present
local local_modules=$(if [ -d node_modules ]; then echo "node_modules:"; fi)
# node_modules in /usr/local/lib if present
local usr_local_modules=$(if [ -d /usr/local/lib/node_modules ]; then echo "/usr/local/lib/node_modules:"; fi)
# node_modules in user's Roaming/npm (Windows) if present
local win_roam_modules=$(if [ -d $(which yo)/../node_modules ]; then echo "$(which yo)/../node_modules:"; fi)
# concat and also add $NODE_PATH
local node_dirs="${local_modules}${usr_local_modules}${win_roam_modules}${NODE_PATH}"
@natchiketa
natchiketa / TapeEquilibrium.js
Created June 23, 2015 19:39
Tape equilibrium solution in JavaScript
function tapeEquilibrium(A) {
var p, idx;
var leftSum = 0, rightSum = 0;
var totalSum = 0;
var lastMin, currentMin;
var N = A.length;
if (N == 2) { return Math.abs(A[0] - A[1]); }
if (N == 1) { return Math.abs(A[0]); }
@natchiketa
natchiketa / environment.prod.ts
Last active June 15, 2017 11:46
environment.prod.ts (Angular CLI v1.1.0)
export const environment = {
production: true
};
@natchiketa
natchiketa / environment.ts
Created June 15, 2017 11:37
environment.ts (Angular CLI v1.1.0)
// The file contents for the current environment will overwrite these during build.
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
// The list of which env maps to which file can be found in `.angular-cli.json`.
export const environment = {
production: false
};