Skip to content

Instantly share code, notes, and snippets.

View ygmpkk's full-sized avatar
😬
No more monkeys jumping on the bed

Timothy ygmpkk

😬
No more monkeys jumping on the bed
  • didi
  • Hangzhou
View GitHub Profile
# THIS FILE HAS BEEN AUTO-GENERATED BY "PRISMA DEPLOY"
# DO NOT EDIT THIS FILE DIRECTLY
#
# Model Types
#
type User implements Node {
id: ID!
name: String!
@WaleedAshraf
WaleedAshraf / workers-mq.js
Last active July 5, 2018 02:57
Switching from cluster module to PM2 & RabbitMQ
// exports RabbitMQ connection
const MQ = require('./rabbitmq-config');
global.smsWorker = {
send: function (message) {
// publish message on sms exchange
return MQ.publish('sms', message);
}
};
@WaleedAshraf
WaleedAshraf / cluster-module.js
Last active July 5, 2018 02:57
Switching from cluster module to PM2 & RabbitMQ
var cluster = require('cluster');
const numCPUs = require('os').cpus().length;
module.exports.create = function (options, callback) {
if (cluster.isMaster) {
// fork child process for notif/sms/email worker
global.smsWorker = require('child_process').fork('./smsWorker');
global.emailWorker = require('child_process').fork('./emailWorker');
global.notifiWorker = require('child_process').fork('./notifWorker');
const dns = require('dns')
const tlds = require('tlds')
dns.setServers([
'80.82.77.83',
//'8.8.8.8',
])
const getAddresses = tld => new Promise((resolve, reject) => {
const domain = 'sci-hub.' + tld
@richardxiong
richardxiong / Nvidia GTX 1080 Ti on MacBook Pro (Akitio Node) with TF.md
Last active November 15, 2023 23:19
Setup Nvidia GPU [GTX 1080 ti] + CUDA 8.0 on MacBook for Deep Learning
@ktmud
ktmud / parse_email.py
Created August 17, 2017 19:34
Python 3.6 Parse Email Message
import re
import email.charset
from pathlib import Path
from glob import glob
from email import message_from_binary_file, policy
RE_QUOPRI_BS = re.compile(r'\b=20=\n')
RE_QUOPRI_LE = re.compile(r'\b=\n')
RE_LONG_WORDS = re.compile(r'\b[\w\/\+\=\n]{72,}\b')
@reagent
reagent / 00_README.md
Last active January 31, 2025 08:46
Custom HTTP Routing in Go

Custom HTTP Routing in Go

Basic Routing

Responding to requests via simple route matching is built in to Go's net/http standard library package. Just register the path prefixes and callbacks you want invoked and then call the ListenAndServe to have the default request handler invoked on each request. For example:

package main

import (
@joostvanveen
joostvanveen / du.sh
Last active March 16, 2023 05:44
Get folder sizes on command line, including --max-depth, sorted by folder size desc
# Get available disk space
df -h
# Get the top 10 biggest folders in the current directory
du -h --max-depth=1 | sort -rh | head -10
# Get the top 10 biggest folders in the current directory and their first child directories
du -h --max-depth=2 | sort -rh | head -10
# Get sizes of all folders in the current directory
@lornajane
lornajane / mac.md
Last active April 28, 2025 18:17
Keyboard Only OS X

Keyboard-only Mac Cheatsheet

Hi, I'm Lorna and I don't use a mouse. I have had RSI issues since a bad workstation setup at work in 2006. I've tried a number of extra hardware modifications but what works best for me is to use the keyboard and only the keyboard, so I'm in a good position and never reaching for anything else (except my coffee cup!). I rather unwisely took a job which required me to use a mac (I've been a linux user until now and also had the ability to choose my tools carefully) so here is my cheatsheet of the apps, tricks and keyboard shortcuts I'm using, mostly for my own reference. Since keyboard-only use is also great for productivity, you may also find some of these ideas useful, in which case at least something good has come of this :)

Apps List

There's more detail on a few of these apps but here is a quick overview of the tools I've installed and found helpful

Tool Link Comments
@rstacruz
rstacruz / _redux.ex
Last active January 18, 2018 11:22
Redux.ex (elixir)
defmodule Redux do
@moduledoc """
Like redux.js, but more elixir-like
store = create_store fn state, action -> ... end
store |> get_state()
store |> dispatch(%{ type: "publish" })
"""
defstruct reducer: nil, state: nil