Skip to content

Instantly share code, notes, and snippets.

View satishbabariya's full-sized avatar

Satish Babariya satishbabariya

View GitHub Profile
const OKCupid = require('okcupidjs');
var Promise = require('bluebird');
var okc = Promise.promisifyAll(new OKCupid());
const baseQuery = { i_want: "women", they_want: "men","maximum_age": 24, radius: 9999 };
const search = async () => {
try {
@satishbabariya
satishbabariya / install-swift-ubuntu.md
Created October 20, 2018 12:06 — forked from Azoy/install-swift-ubuntu.md
Guide on how to install Swift on Ubuntu

Install Swift on Ubuntu

Requirements

  1. Ubuntu 14.04, 16.04, or 16.10

Step 1 - Dependencies

  1. Open up terminal
  2. Install core deps: sudo apt-get install clang libicu-dev git

Step 1.1 - Ubuntu 14.04 Clang

import * as React from "react";
import * as monaco from 'monaco-editor-core/esm/vs/editor/editor.main';
// (self as any).MonacoEnvironment = {
// getWorkerUrl: () => './editor.worker.bundle.js',
// };
class Editor extends React.Component {
  • Use curl to get the JSON response for the latest release
  • Use grep to find the line containing file URL
  • Use cut and tr to extract the URL
  • Use wget to download it
curl -s https://api.github.com/repos/jgm/pandoc/releases/latest \
| grep "browser_download_url.*deb" \
| cut -d : -f 2,3 \
| tr -d \" \
import Resty
struct Todo: Codable {
let id: Int
let title: String
let completed: Bool
}
enum FakeAPI: Resty {
case todos
enum MyService {
case zen
case showUser(id: Int)
case createUser(firstName: String, lastName: String)
case updateUser(id: Int, firstName: String, lastName: String)
case showAccounts
}
// MARK: - Resty Protocol Implementation
extension MyService: Resty {
var host: String {
return "https://jsonplaceholder.typicode.com/"
}
var path: String {
return ""
}
MyService.zen.request(type: [Todo].self) { result in
switch result {
case let .success(todos):
// Array of [Todo]
case let .failure(error):
// error
}
}
@satishbabariya
satishbabariya / Swift Property Wrappers.md
Last active September 30, 2019 15:24
Swift Property Wrappers

Swift Property Wrappers Written by Mattt June 24th, 2019 Years ago, we remarked that the “at sign” (@) — along with square brackets and ridiculously-long method names — was as characteristic of Objective-C as parentheses are to Lisp or punctuation is to Perl.

Then came Swift, and with it an end to these curious little 🥨-shaped glyphs. Or so we thought.

At first, the function of @ was limited to Objective-C interoperability: @IBAction, @NSCopying, @UIApplicationMain, and so on. But in time, Swift has continued to incorporate an ever-increasing number of @-prefixed attributes.

We got our first glimpse of Swift 5.1 at WWDC 2019 by way of the SwiftUI announcement. And with each “mind-blowing” slide came a hitherto unknown attribute: @State, @Binding, @EnvironmentObject…

@satishbabariya
satishbabariya / commit.sh
Created October 13, 2019 04:09
Git, rewrite previous commit usernames and emails
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="oldEmail@xxx-MacBook-Pro.local"
CORRECT_NAME="Satish Babariya"
CORRECT_EMAIL="satish.babariya@gmail.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then