This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package twitter_api | |
import ( | |
"fmt" | |
"strconv" | |
"github.com/buger/jsonparser" | |
) | |
/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func ping() { | |
let req = PingRequest() | |
ExampleService.ping(with: 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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
Pool::builder() | |
.max_size(5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
operation.* | |
FROM | |
operations operation | |
LEFT JOIN LATERAL ( | |
SELECT | |
_r.state | |
FROM | |
operations_results _r | |
WHERE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# With BSNL Broadband (8Mbps 2841 plan), outgoing connections on | |
# *port 22* (ssh) consistently time out. This happens on all servers, | |
# not necessarily github.com. | |
$ telnet github.com 22 | |
Trying 192.30.255.112... | |
telnet: connect to address 192.30.255.112: Operation timed out | |
Trying 192.30.255.113... | |
telnet: connect to address 192.30.255.113: Operation timed out | |
telnet: Unable to connect to remote host |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://play.golang.org/p/P5DDZrcXZB | |
package main | |
import "fmt" | |
type Monad interface { | |
Bind(func(interface{}, Monad) Monad) Monad | |
Return(interface{}) Monad | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Like SGo | |
var regularVar: String | |
// This will _not compile_. | |
// print(regularVar) | |
// This will _not compile_. | |
// regularVar = nil |