Skip to content

Instantly share code, notes, and snippets.

View paambaati's full-sized avatar
🏠

GP paambaati

🏠
View GitHub Profile
@paambaati
paambaati / myproject.conf
Created February 20, 2015 15:47
Sample nginx config with redirection issue
upstream myproject_upstream {
server 127.0.0.1:3000;
}
server {
listen 80;
root /Users/myusername/Projects/myproject/static;
server_name servername.com;
@paambaati
paambaati / tasker_airtel.xml
Created June 15, 2015 08:58
Tasker task to get a notification of your Airtel broadband usage
<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 / getNearest.js
Created October 22, 2015 04:10
Applying a filter on .getNearest() using RethinkDB and Thinky
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 / mongo_add_admin.js
Created May 17, 2014 05:20
Add an administrator account to MongoDB instance
db.createUser(
{
user: "admin_username",
pwd: "admin_password",
roles:
[
{
role: "userAdminAnyDatabase",
db: "admin"
}
@paambaati
paambaati / index.d.ts
Created January 7, 2019 10:57
Type definitions for chrome-remote-interface
// Type definitions for chrome-remote-interface 0.26.1
// Project: https://github.com/cyrus-and/chrome-remote-interface
// Definitions by: GP <https://github.com/paambaati>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = CDP;
declare function CDP(options?: CDP.ChromeRemoteInterfaceOptions): CDP.CDP;
declare namespace CDP {
@paambaati
paambaati / map2json.js
Last active January 16, 2019 07:36
JSON stringifier that handles ES6 Maps
// Optional: If any dependency is overriding Map's toJSON function,
// you might want to reset it.
// Why? See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#toJSON()_behavior
delete Map.prototype.toJSON;
function customStringifier(key, value) {
if (value instanceof Map) {
// Convert Maps to JSON objects.
let obj = Object.create(null);
for (let [k, v] of value) {
@paambaati
paambaati / marathon_migrate.py
Last active February 20, 2019 04:22
Handy script to help migrate all Mesos Marathon apps from 1 cluster to another. Can use either a Marathon URI or a local file location for both source & destination sinks. Works on both Python2 & Python3.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
from os import environ
from json import load, loads, dumps
from urlparse import urlparse
try:
from urllib.request import urlopen, Request
from urllib.error import HTTPError
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
GRPC_VERBOSITY=DEBUG GRPC_TRACE=all yarn run debug
yarn run v1.17.3
$ ts-node src/debug.ts
D0908 08:17:51.870543000 4400821696 dns_resolver.cc:294] Using native dns resolver
I0908 08:17:51.870996000 4400821696 timer_manager.cc:85] Spawn timer thread
I0908 08:17:51.871014000 4400821696 init.cc:163] grpc_init(void)
I0908 08:17:51.871060000 123145562341376 timer_manager.cc:246] timers not checked: expect another thread to
I0908 08:17:51.871069000 123145562341376 timer_manager.cc:194] sleep until kicked
I0908 08:17:51.871329000 4400821696 completion_queue.cc:504] grpc_completion_queue_create_internal(completion_type=0, polling_type=0)
@paambaati
paambaati / select.tsx
Created April 12, 2020 10:40
react-select + react-hook-form
import { forwardRef } from 'react';
import Select from 'react-select';
import { Controller } from 'react-hook-form';
import type { RefObject } from 'react';
import type { Props as ReactSelectProps } from 'react-select';
const Select = forwardRef(
(props: SelectProps, ref: RefObject<HTMLSelectElement>) => {
return (
<Controller