Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View nickleefly's full-sized avatar

Xiuyu Li nickleefly

  • Shanghai
View GitHub Profile
@nickleefly
nickleefly / npx-osx.md
Created December 10, 2017 08:40 — forked from tamzinblake/npx-osx.md
How to get npx shell auto fallback working on OSX bash

OSX ships with bash 3 by default, but you need bash 4 to use npx shell auto fallback. Using homebrew:

(instructions borrowed from https://github.com/Homebrew/homebrew-command-not-found)

brew update && brew install bash
# Add the new shell to the list of allowed shells
sudo bash -c 'echo /usr/local/bin/bash >> /etc/shells'
# Change to the new shell
chsh -s /usr/local/bin/bash
@nickleefly
nickleefly / initialize_basic_user.yml
Created September 11, 2017 07:53
ansible playbook setup user
---
- hosts: linode
remote_user: root
vars:
NORMAL_USER_NAME: 'yourusername'
tasks:
- name: Make sure we have a 'wheel' group
group:
name: wheel
state: present
@nickleefly
nickleefly / Ansible-Vault how-to.md
Created September 7, 2017 03:18 — forked from tristanfisher/Ansible-Vault how-to.md
A short tutorial on how to use Vault in your Ansible workflow. Ansible-vault allows you to more safely store sensitive information in a source code repository or on disk.

##Working with ansible-vault

I've been using a lot of Ansible lately and while almost everything has been great, finding a clean way to implement ansible-vault wasn't immediately apparent.

What I decided on was the following: put your secret information into a vars file, reference that vars file from your task, and encrypt the whole vars file using ansible-vault encrypt.

Let's use an example: You're writing an Ansible role and want to encrypt the spoiler for the movie Aliens.

function invert(tree) {
if (!(tree instanceof Array) || tree.length === 1) return tree;
var ret = [];
var inverted = tree.reverse();
for(var cur in inverted) {
if(!inverted.hasOwnProperty(cur)) continue;
ret.push(inverted[cur] instanceof Array ? invert(inverted[cur]) : inverted[cur]);
}
@nickleefly
nickleefly / install-terraform-packer.sh
Last active March 22, 2018 14:27
install terraform and packer osx
#!/usr/bin/env bash
# Script prerequisite > install jq > https://stedolan.github.io/jq/download/
cd ~
# Prerequisites
if [ "$(uname)" == "Darwin" ]; then
brew install jq
# For Linux
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
@nickleefly
nickleefly / readme.md
Last active May 28, 2022 12:06
openwrt on newwifi Y1

Resources:

  • [lenovo_y1_v1][1]
  • [hiwifi hc5861][8]
  • [openwrt hiwifi][9]

newwifi is MTK board(MediaTek MT7620A), find the builds for ramips

How to install

@nickleefly
nickleefly / bench.js
Last active March 24, 2016 09:40
isArray bench
var benchmark = require('benchmark')
var benchmarks = require('beautify-benchmark')
global.isArray = require('./index')
global.assert = require('assert')
var suite = new benchmark.Suite
var assertValues = 'assert.strictEqual(obj, true);'
suite.add({
@nickleefly
nickleefly / closest.js
Last active March 10, 2016 03:36
get closest number from an array
var counts = [4, 9, 15, 100, 2],
goal = 70;
function closest(array, x) {
var min,
chosen = array[0];
for (var i in array) {
min = Math.abs(x - chosen);
if (Math.abs(x - array[i]) < min) {
chosen = array[i];
@nickleefly
nickleefly / prime-generator.js
Last active January 12, 2016 09:56 — forked from trevnorris/prime-generator.js
fastest js prime generator been able to get http://jsperf.com/123123123456
// Thanks to @isntitvacant (https://github.com/chrisdickinson) for optimizing the
// bit shift performance tweaks.
var SB = require('buffer').SlowBuffer;
var ITER = 2e4;
var SIZE = 1e3;
function genPrimes(max) {
var primes = new Array();
var len = (max >>> 3) + 1;