Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠

GP paambaati

🏠
View GitHub Profile
@paambaati
paambaati / got.js
Last active Dec 24, 2018
Got with HTTP2 support (ALPN negotiation) + Connect settings overrides
View got.js
const {extend: gotExtend} = require('got');
const http2 = require('http2-wrapper');
const resolveALPN = require('resolve-alpn');
// Taken from https://github.com/nodejs/node/blob/d4c91f28148af8a6c1a95392e5c88cb93d4b61c6/lib/_http_agent.js
//
// throws
// tls.connect({host: 'httpbin.org', port: 443});
//
// doesn't throw
@paambaati
paambaati / PDFtoHTML.scala
Created Dec 19, 2018
Extracting HTML from PDFs
View PDFtoHTML.scala
package me
import java.io.{File, FileInputStream}
import org.apache.pdfbox.pdmodel.PDDocument
import org.apache.pdfbox.tools.PDFText2HTML
object PDFtoHTML {
def main(args: Array[String]): Unit = {
val stream = new FileInputStream(new File("/Users/me/Downloads/example.pdf"))
@paambaati
paambaati / mongo_add_admin.js
Created May 17, 2014
Add an administrator account to MongoDB instance
View mongo_add_admin.js
db.createUser(
{
user: "admin_username",
pwd: "admin_password",
roles:
[
{
role: "userAdminAnyDatabase",
db: "admin"
}
@paambaati
paambaati / getNearest.js
Created Oct 22, 2015
Applying a filter on .getNearest() using RethinkDB and Thinky
View getNearest.js
const userId = '2ff8902e-97f0-431a-a51c-900a57532967';
const location = r.point(-20, 39);
const queryOptions = {index: 'location'};
// Getting nearest list of users, while also excluding `userId`.
UserModel.getNearest(location, queryOptions)
.filter(r.row('doc')('id').ne(userId))
.run();
@paambaati
paambaati / tasker_airtel.xml
Created Jun 15, 2015
Tasker task to get a notification of your Airtel broadband usage
View tasker_airtel.xml
<TaskerData sr="" dvi="1" tv="4.7u1m">
<Task sr="task5">
<cdate>1414934667539</cdate>
<edate>1434358392316</edate>
<id>5</id>
<nme>Check Airtel Broadband Usage</nme>
<pri>10</pri>
<Action sr="act0" ve="7">
<code>118</code>
<Str sr="arg0" ve="3">http://122.160.230.125:8080</Str>
@paambaati
paambaati / myproject.conf
Created Feb 20, 2015
Sample nginx config with redirection issue
View myproject.conf
upstream myproject_upstream {
server 127.0.0.1:3000;
}
server {
listen 80;
root /Users/myusername/Projects/myproject/static;
server_name servername.com;