Skip to content

Instantly share code, notes, and snippets.

Gurpartap Singh Gurpartap

Block or report user

Report or block Gurpartap

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
Gurpartap / one-way-hashing-function.swift
Created Apr 28, 2019
Swift port of Apple's one-way hashing function for setting SKMutablePayment's applicationUsername
View one-way-hashing-function.swift
// Objective-C version available here:
// Usage:
// let userID = "146001"
// print(hashedValueForAccountName(userID))
// Output:
Gurpartap / cursored_resp.go
Created Sep 9, 2018
#golang jsonparser with twitter api responses
View cursored_resp.go
package twitter_api
import (
Gurpartap / ExampleClient.swift
Last active Aug 27, 2018
gRPC Status Details (custom error data) with Swift (grpc-objc)
View ExampleClient.swift
func ping() {
let req = PingRequest() req) { (response, error) in
if let error = error {
var title = "Unknown error"
var message = error.localizedDescription
for detail in try! RPCStatus.from(error)?.details ?? [] {
switch detail {
Gurpartap /
Last active Aug 1, 2018
diesel example w/ r2d2 pool
use diesel::prelude::*;
use diesel::r2d2::{ConnectionManager, Pool};
use diesel::result::Error as DieselError;
use models::User;
use schema::users;
pub fn establish_connection(database_url: String) -> Pool<ConnectionManager<PgConnection>> {
let manager = ConnectionManager::<PgConnection>::new(database_url);
Gurpartap / UITableView+ObservableArray_RxSwift.swift
Last active Feb 19, 2018
rx_autoUpdater for ObservableArray-RxSwift
View UITableView+ObservableArray_RxSwift.swift
import UIKit
import RxSwift
import ObservableArray_RxSwift
extension UITableView {
public func rx_autoUpdater(source: Observable<ArrayChangeEvent>) -> Disposable {
return source
.scan((0, nil)) { (a: (Int, ArrayChangeEvent?), ev) in
(a.0 + ev.insertedIndices.count - ev.deletedIndices.count, ev)
View lock_operation.sql
operations operation
operations_results _r
Gurpartap /
Last active Oct 28, 2017
Proof of port 22 blocked by BSNL
# With BSNL Broadband (8Mbps 2841 plan), outgoing connections on
# *port 22* (ssh) consistently time out. This happens on all servers,
# not necessarily
$ telnet 22
telnet: connect to address Operation timed out
telnet: connect to address Operation timed out
telnet: Unable to connect to remote host
Gurpartap / 1_schema.sql
Last active Mar 24, 2017
select x where latest y of x is z
View 1_schema.sql
create table tasks (
id serial primary key,
name text not null
create table results (
id serial primary key,
created_at timestamptz default now() not null,
state text default null,
task_id int references tasks(id)
Gurpartap / authorize-api-request.go
Last active Dec 2, 2016
Authorize api request with api key and secret
View authorize-api-request.go
package main
import (
Gurpartap / maybe.go
Created Oct 9, 2016
Maybe Monad in Go
View maybe.go
package main
import "fmt"
type Monad interface {
Bind(func(interface{}, Monad) Monad) Monad
Return(interface{}) Monad
You can’t perform that action at this time.