Skip to content

Instantly share code, notes, and snippets.

View yields's full-sized avatar
:octocat:
☕ 💻

Amir Abushareb yields

:octocat:
☕ 💻
View GitHub Profile
@dolphin278
dolphin278 / README.md
Last active February 12, 2022 16:30
Pub/sub example for nodejs using mongodb

Uses capped collection, tailable cursors and streams.

What's here?

  • init.js recreates collection capped collection 'queue' on mongodb.
  • writer.js spams queue with new messages
  • worker.js processes all messages saved to queue,
  • onceWorker.js processes only unprocessed messages, so you can spawn several of them and each of your messages will be processed by only one worker.

Steps

@KonTrax
KonTrax / 00_tableOnly.py
Last active November 23, 2020 08:09
SublimeText3 Theme Overview
#### ALL CLASSES
# Unsorted at the moment
|===========================|======|==================|====================|=================|========|==================|
| CLASS | TYPE | ATTRIBUTES | PROPERTIES | FONT.PROPERTIES | LAYERS | LAYER.PROPERTIES |
|===========================|======|==================|====================|=================|========|==================|
| auto_complete | | | row_padding | | layer0 | tint |
| | | | dark_content | | | opacity |
|---------------------------|------|------------------|--------------------|-----------------|--------|------------------|
| auto_complete_label | | | fg | | | |
| | | | match_fg | | |
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active July 5, 2024 04:29
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@ericchen
ericchen / gist:3081970
Created July 10, 2012 08:11
nodejs AES encrypt and decrypt
var crypto = require('crypto');
var AESCrypt = {};
AESCrypt.decrypt = function(cryptkey, iv, encryptdata) {
encryptdata = new Buffer(encryptdata, 'base64').toString('binary');
var decipher = crypto.createDecipheriv('aes-256-cbc', cryptkey, iv),
decoded = decipher.update(encryptdata);
@kennonb
kennonb / gist:2901006
Created June 9, 2012 13:37
Text Editor Font Smoothing (Textmate & Sublime Text 2)
/*
Found this handy little tip here:
http://madeofcode.com/posts/12-snow-leopard-textmate-font-smoothing
*/
/* TextMate */
defaults write com.macromates.textmate AppleFontSmoothing -int 1
/* Sublime Text 2 */
defaults write com.sublimetext.2 AppleFontSmoothing -int 1
@creationix
creationix / coroutine-example.js
Created November 8, 2011 22:14
Lua style coroutines in nodeJS proposal
var FS = require('fs');
var Fiber = require('./fiber'); // Not to be confused with the existing node-fibers module
// readFile is a normal non-blocking, async function, but internally it can use
// the coroutine helper fiber. These kinds of coroutines are no more dangerous
// to the caller than any other async function.
function readfile(filename, next) {
// The call to Fiber is non-blocking. It's contents are only run sync till
// the first call to wait and then it returns.
Fiber(function (resume, wait) {