Skip to content

Instantly share code, notes, and snippets.

@chenshuo
chenshuo / score_rank.cc
Created March 3, 2012 16:13
Update score and get rank in real time
#include <vector>
#include <assert.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
typedef int32_t Score;
typedef int32_t UserId;
typedef int32_t Rank;
const Score kInvalidScore = -1;
@qzaidi
qzaidi / jsstack.js
Created August 4, 2012 04:21
jsstack - pstack like tool for node.js apps
#!/usr/bin/env node
"use strict";
var debug = require('_debugger');
var c = new debug.Client();
function main() {
console.log('requesting trace');
c.reqBacktrace(function(err,trace) {
if (!err) {
@jppommet
jppommet / int2ip.js
Last active November 5, 2024 08:56
javascript conversion from ip address to long integer and vice versa
function int2ip (ipInt) {
return ( (ipInt>>>24) +'.' + (ipInt>>16 & 255) +'.' + (ipInt>>8 & 255) +'.' + (ipInt & 255) );
}
@coolnalu
coolnalu / gist:7992954
Created December 16, 2013 19:34
Ubuntu 11.10 monitor won’t wakeup after fall asleep
## vim /etc/X11/xorg.conf and add
Section "ServerFlags"
Option "BlankTime" "0"
Option "StandbyTime" "0"
Option "SuspendTime" "0"
Option "OffTime" "0"
Option "DontZap" "false"
Option "dpms" "false"
EndSection
@zxc122333
zxc122333 / pomelo-client.js
Created July 14, 2014 06:10
pomelo-client.js
var WebSocket = require('ws');
var Protocol = require('pomelo-protocol');
var Package = Protocol.Package;
var Message = Protocol.Message;
var EventEmitter = require('events').EventEmitter;
var protobuf = require('pomelo-protobuf');
var util = require('util');
var thunkify = require("thunkify");
var JS_WS_CLIENT_TYPE = 'js-websocket';
var JS_WS_CLIENT_VERSION = '0.0.1';
@Yimiprod
Yimiprod / difference.js
Last active April 6, 2025 09:16
Deep diff between two object, using lodash
/**
* This code is licensed under the terms of the MIT license
*
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {
@cpsubrian
cpsubrian / README.md
Last active December 6, 2023 11:03
Compile Xvfb for AWS Lamba
@lukeplausin
lukeplausin / bash_aws_jq_cheatsheet.sh
Last active January 4, 2025 17:42
AWS, JQ and bash command cheat sheet. How to query, cut and munge things in JSON generally.
# Count total EBS based storage in AWS
aws ec2 describe-volumes | jq "[.Volumes[].Size] | add"
# Count total EBS storage with a tag filter
aws ec2 describe-volumes --filters "Name=tag:Name,Values=CloudEndure Volume qjenc" | jq "[.Volumes[].Size] | add"
# Describe instances concisely
aws ec2 describe-instances | jq '[.Reservations | .[] | .Instances | .[] | {InstanceId: .InstanceId, State: .State, SubnetId: .SubnetId, VpcId: .VpcId, Name: (.Tags[]|select(.Key=="Name")|.Value)}]'
# Wait until $instance_id is running and then immediately stop it again
aws ec2 wait instance-running --instance-id $instance_id && aws ec2 stop-instances --instance-id $instance_id
# Get 10th instance in the account
@MeLlamoPablo
MeLlamoPablo / nvmlink
Created February 1, 2017 11:34
Creates a symlink to /usr/bin/node after using nvm
@Sg4Dylan
Sg4Dylan / viewer_loader_0.1.8_2018-02-09.js
Last active September 12, 2023 15:09
bookwalker.com.tw online reader DRM
/**
Open Source Software Licenses
PUBLUS
Copyright(c) 2013-2014 ACCESS CO., LTD. All rights reserved.
This software includes all or part of the following open source software which is available under each license terms and conditions as follows:
* LAB.js (LABjs :: Loading And Blocking JavaScript)
v2.0.3 (c) Kyle Simpson