Skip to content

Instantly share code, notes, and snippets.

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

Damien Guard damieng

🏠
Working from home
View GitHub Profile
@damieng
damieng / Lightsaver-G80-1800-style.kbd.json
Last active December 16, 2016 18:27
Lightsaver G80-1800 style
[
{
"name": "Lightsaver G80-1800 style",
"author": "Damien Guard",
"background": {
"name": "Steel brushed dark",
"style": "background-image: url('/bg/metal/iron_texture1745.jpg');"
},
"switchMount": "cherry",
"switchBrand": "cherry",
@damieng
damieng / Compaq-G80-1800.kbd.json
Last active December 13, 2016 03:55
Compaq G80-1800
[
{
"backcolor": "#000000",
"name": "Compaq G80-1800",
"author": "Damien Guard",
"background": {
"name": "ABS WFK",
"style": "background-image: url('/bg/plastic/abs-wfk.jpg');"
},
"switchMount": "cherry",
@damieng
damieng / npm-win-proxy.ps1
Last active September 21, 2017 10:04
Apply Windows proxy settings to npm automatically
try {
$proxyKey = (Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name ProxyServer -ErrorAction Stop).ProxyServer
foreach($proxy in $proxyKey.Split(';')) {
$parts = $proxy.Split('=')
switch ($parts[0]) {
'http' { iex "npm config set proxy http://$parts[1]"; break }
'https' { iex "npm config set https-proxy http://$parts[1]"; break }
}
}
}
@damieng
damieng / getproxieswindows.js
Created January 11, 2017 22:22
Get Proxy servers on Windows
exports.getProxyServers = (callback) => {
try {
new Registry('\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings')
.get('ProxySever', (err, val) => {
callback(err, err ? undefined || Object.assign({}, ...val.split(';').map(v => v.split('=')).map(v => ({[v[0]]: v[1]}))))
})
} catch (err) {
callback(err)
}
### Keybase proof
I hereby claim:
* I am damieng on github.
* I am damieng (https://keybase.io/damieng) on keybase.
* I have a public key ASA8deTgucv6MkZXIKGoqPTL9-Tw1C1HZPVR_iOyfEsQfgo
To claim this, I am signing this object:
@damieng
damieng / download-with-fetch.flow.js
Created March 13, 2017 20:43
Download a file using just window.fetch (flowtype version)
// @flow
import fs from 'fs';
export default async function download(sourceUrl: string, targetFile: string, progressCallback: ?ByteProgressCallback, length: ?number): Promise<void> {
const request = new Request(sourceUrl, {
headers: new Headers({'Content-Type': 'application/octet-stream'})
});
const response = await fetch(request);
@damieng
damieng / download-with-fetch.flow.js
Last active April 13, 2023 01:17
Download a file with progress indication using just window.fetch + node (FlowType version)
// @flow
import fs from 'fs';
// Public: Download a file and store it on a file system using streaming with appropriate progress callback.
//
// * `sourceUrl` Url to download from.
// * `targetFile` File path to save to.
// * `progressCallback` Callback function that will be given a {ByteProgressCallback} object containing
// both bytesDone and percent.
@damieng
damieng / daily-backup.sh
Last active October 6, 2017 15:37
DamienG daily backup script to S3
cd ~/backup
rm *
_today=$(date +"%Y%m%d")
tar -c --xz -f $_today-nginx-config-dedicated.tar.xz -C /etc nginx
tar -c --xz -f $_today-damieng-files.tar.xz -C /var/www damieng
mysqldump wpDamieng | xz -9 -c - > $_today-damieng-wordpress-db.xz
cp ../*.sh .
@damieng
damieng / PageViewCount.csx
Created May 16, 2017 03:47
Page View Count function in C# for Azure Functions
#r "Microsoft.WindowsAzure.Storage"
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using System.Net;
public static async Task<object> Run(HttpRequestMessage req, TraceWriter log)
{
var page = req.GetQueryNameValuePairs().FirstOrDefault(kv => string.Compare(kv.Key, "page", true) == 0);
if (String.IsNullOrEmpty(page.Value)) return req.CreateResponse(HttpStatusCode.BadRequest);
@damieng
damieng / AwfulCSharpCode.cs
Created May 16, 2017 18:46
A sample C# file that messes with syntax highlighters
extern alias b;
using System;
class A { public dictionary<int, String> func(int a) { } }
struct hi { byte q; int a = /* */ 1; char c = 'c'; }
void A() { }
#if ABC // Testing
#endif
/* Mult-line
comment */
public abstract class Outside { }