Skip to content

Instantly share code, notes, and snippets.

View cheeming's full-sized avatar

Chew Chee Ming cheeming

View GitHub Profile
@enricofoltran
enricofoltran / main.go
Last active October 3, 2024 14:08
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
@dfletcher
dfletcher / tsws
Last active July 21, 2018 12:47
Totally simple web server using Bash and netcat (nc)
Moved to a proprer repositoy, TSWS is a real boy now!
https://github.com/dfletcher/tsws
PRs welcomed.
@cheeming
cheeming / making-jquery-mobile-page-transitions-work-well-with-android-4.1.md
Last active August 29, 2015 14:18
Making jQuery Mobile page transitions work well with Android 4.1
  • We are using:
    • Cordova v4.3.0
    • jQuery Mobile v1.4.5
  • We would like page transitions to be animated nicely
  • Android 4.1 doesn't play ball
  • We use the standard jQuery Mobile pages with fixed header, and we've disabled tap toggle
  • We find that we get 2 problems
    • White flashes, flickering, in between the page transitions
    • Also the content of the page gets pushed underneath the fixed header, when we remove previously inserted pages (we do this to deal with memory / performance issues)
  • And user is able to tap hold and prompt up the user selection options / widgets, i.e. copy and paste
@ndarville
ndarville / business-models.md
Last active October 23, 2024 17:18
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@klange
klange / _.md
Last active September 27, 2024 11:04
It's a résumé, as a readable and compilable C source file. Since Hacker News got here, this has been updated to be most of my actual résumé. This isn't a serious document, just a concept to annoy people who talk about recruiting and the formats they accept résumés in. It's also relatively representative of my coding style.

Since this is on Hacker News and reddit...

  • No, I don't distribute my résumé like this. A friend of mine made a joke about me being the kind of person who would do this, so I did (the link on that page was added later). My actual résumé is a good bit crazier.
  • I apologize for the use of _t in my types. I spend a lot of time at a level where I can do that; "reserved for system libraries? I am the system libraries".
  • Since people kept complaining, I've fixed the assignments of string literals to non-const char *s.
  • My use of type * name, however, is entirely intentional.
  • If you're using an older compiler, you might have trouble with the anonymous unions and the designated initializers - I think gcc 4.4 requires some extra braces to get them working together. Anything reasonably recent should work fine. Clang and gcc (newer than 4.4, at le
@cheeming
cheeming / patch-fix-slave-ok-flag.diff
Created August 5, 2012 11:28
Patch to fix mongo c driver to allow connection to secondary/slave mongodb instances. This patch will apply cleanly on revision 13808396bd1b128dfa03ea3ba4d3cdccb9d990c7 for https://github.com/mongodb/mongo-c-driver
diff --git a/src/gridfs.c b/src/gridfs.c
index f51b397..66f8d88 100644
--- a/src/gridfs.c
+++ b/src/gridfs.c
@@ -43,7 +43,7 @@ int gridfs_init( mongo *client, const char *dbname, const char *prefix,
int options;
bson b;
- bson_bool_t success;
+ bson_bool_t success = 1;
@cheeming
cheeming / patch-fix-slave-ok-flag2.diff
Created August 5, 2012 11:19
Patch to fix nginx gridfs module to allow connection to secondary/slave mongodb instances. This patch will apply cleanly on revision 76225528b3903fc9eafcb8163c7ebfdf34237e8b for https://github.com/mdirolf/nginx-gridfs.
diff --git a/ngx_http_gridfs_module.c b/ngx_http_gridfs_module.c
index 77ef430..859dff1 100644
--- a/ngx_http_gridfs_module.c
+++ b/ngx_http_gridfs_module.c
@@ -490,7 +490,7 @@ static ngx_int_t ngx_http_mongo_add_connection(ngx_cycle_t* cycle, ngx_http_grid
if ( gridfs_loc_conf->mongods->nelts == 1 ) {
ngx_cpystrn( host, mongods[0].host.data, mongods[0].host.len + 1 );
- status = mongo_connect( &mongo_conn->conn, (const char*)host, mongods[0].port );
+ status = mongo_connect( &mongo_conn->conn, (const char*)host, mongods[0].port, MONGO_SECONDARY_OK );
@jboner
jboner / latency.txt
Last active November 16, 2024 21:28
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD