Skip to content

Instantly share code, notes, and snippets.

View lukedesu's full-sized avatar
🏠
Working from home

Luke Luo lukedesu

🏠
Working from home
  • Singapore
  • 04:31 (UTC +08:00)
View GitHub Profile
@lukedesu
lukedesu / cloudflare.sh
Last active May 30, 2024 05:59
Setting Up Automatic Cloudflare DNS Updates with Cron
#!/bin/bash
auth_email="example@gmail.com" # The email used to login 'https://dash.cloudflare.com'
auth_key="YOUR_KEY" # Top right corner, "My profile" > "Global API Key"
zone_identifier="YOUR_ZONE_ID" # Can be found in the "Overview" tab of your domain, Zone ID is at the right bottom
record_names=("www.example.com" "example.com") # List of records you want to be synced
proxy=false # Set the proxy to true or false
log_file="$(dirname "$0")/update-logs.log"
ip_file="$(dirname "$0")/current_ip.txt"
@ferenczy
ferenczy / atom-get-lost-unsaved-buffers.js
Last active May 29, 2024 21:09
Get lost unsaved buffers in Atom editor: Load text content of all unsaved buffers stored by Atom for any project and print it to Developers tools console
/**
* Get lost unsaved buffers in Atom editor
*
* Load text content of all unsaved buffers stored by Atom for any project in IndexedDB and print it to Developers tools console
*
* Author: David Ferenczy Rogožan (https://ferenczy.cz)
*
* Instructions:
*
* 1. Start Atom
#!/usr/bin/env bash
read -r -d '' usage << EOM
Usage:
gh-deploy-clone user/repo [ENVIRONMENT]
EOM
[ -z "$1" ] && echo && echo "$usage" && echo && exit 1
@otiai10
otiai10 / golang_jwt_example.go
Last active May 25, 2021 15:47
Golang JWT Example (2017/Oct/26)
package main
import (
"log"
jwt "github.com/dgrijalva/jwt-go"
)
type User struct {
Name string `json:"name"`
@uorat
uorat / nginx-websocket-proxy.conf
Last active September 6, 2024 21:32
Nginx Reverse Proxy for WebSocket
upstream websocket {
server localhost:3000;
}
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/websocket.access.log main;
export const GoogleApi = function(opts) {
opts = opts || {}
const apiKey = opts.apiKey;
const libraries = opts.libraries || [];
const client = opts.client;
const URL = 'https://maps.googleapis.com/maps/api/js';
const googleVersion = '3.22';
let script = null;
//
// ViewController.swift
// starWarsTableViewUpdates
//
// Created by Christina Moulton on 2015-10-17.
// Copyright (c) 2015 Teak Mobile Inc. All rights reserved.
//
import UIKit
@brianmacarthur
brianmacarthur / flash-app.js
Last active September 14, 2024 17:22
Flash messaging in Express 4: express-flash vs. custom middleware in ejs, handlebars, or jade
var express = require('express');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var flash = require('express-flash');
var handlebars = require('express-handlebars')
var app = express();
var sessionStore = new session.MemoryStore;
// View Engines
@gubatron
gubatron / multiple-deploy-keys-multiple-private-repos-github-ssh-config.md
Last active July 10, 2024 03:50
How to configure multiple deploy keys for different private github repositories on the same computer without using ssh-agent

How to configure multiple deploy keys for different private github repositories on the same computer without using ssh-agent

Let's say alice is a github.com user, with 2 or more private repositories repoN. For this example we'll work with just two repositories named repo1 and repo2

https://github.com/alice/repo1

https://github.com/alice/repo2

You need to be to pull from these repositories without entering a passwords probably on a server, or on multiple servers.

@colingourlay
colingourlay / example.js
Last active October 22, 2021 15:16
Lodash / Underscore sort object keys. Like _.sortBy(), but on keys instead of values, returning an object, not an array. Defaults to alphanumeric sort.
var obj = {b: 3, c: 2, a: 1};
_.sortKeysBy(obj);
// {a: 1, b: 3, c: 2}
_.sortKeysBy(obj, function (value, key) {
return value;
});
// {a: 1, c: 2, b: 3}