Skip to content

Instantly share code, notes, and snippets.

View eashish93's full-sized avatar

Ashish Rawat eashish93

View GitHub Profile
@paolorotolo
paolorotolo / RealmBackupRestore.java
Last active June 17, 2018 17:31
Class to easily backup/restore data from Realm.
package org.glucosio.android.tools;
import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Environment;
import android.support.v4.app.ActivityCompat;
import android.util.Log;
import android.widget.Toast;
@hilkeheremans
hilkeheremans / howto
Last active December 8, 2020 19:20
Fonts in React Native for Android vs iOS
REACT NATIVE IOS vs ANDROID FONT USE
Tested for React Native 0.41+
IOS:
- Place the fonts in the assets and make sure they are bundled along
- On iOS, fontFamily in Text match the Font Family name as described in Font Book (macOS). Font weights can be specified exactly.
ANDROID:
On Android, there are two ways of using fonts:
@BrianHung
BrianHung / Editor.tsx
Created April 29, 2022 09:16
ProseMirror and Granular Updates with React useSyncExternalStore
import React, { createContext, useContext, useState, useRef } from "react"
import { EditorView, EditorProps } from "prosemirror-view"
import { useSyncExternalStore } from "use-sync-external-store/shim"
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/with-selector"
import { memo, useEffect } from "react"
import { useEditorContext } from "./hooks/useEditor"
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@chilts
chilts / alexa.js
Created October 30, 2013 09:27
Getting the Alexa top 1 million sites directly from the server, unzipping it, parsing the csv and getting each line as an array.
var request = require('request');
var unzip = require('unzip');
var csv2 = require('csv2');
request.get('http://s3.amazonaws.com/alexa-static/top-1m.csv.zip')
.pipe(unzip.Parse())
.on('entry', function (entry) {
entry.pipe(csv2()).on('data', console.log);
})
;
@vidarh
vidarh / closures-basic.c
Created December 18, 2009 12:10
A number of ways to implement closures in C, in preparation of an upcoming blog post
#include <stdio.h>
#include <stdlib.h>
struct closure {
void (* call)(struct closure *);
int x;
};
@mikaelbr
mikaelbr / destructuring.js
Last active February 21, 2024 20:41
Complete collection of JavaScript destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
@chantastic
chantastic / on-jsx.markdown
Last active March 20, 2024 01:03
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't

@LeCoupa
LeCoupa / bash-cheatsheet.sh
Last active March 31, 2024 11:57
Bash CheatSheet for UNIX Systems --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@nadavrot
nadavrot / Matrix.md
Last active April 2, 2024 06:45
Efficient matrix multiplication

High-Performance Matrix Multiplication

This is a short post that explains how to write a high-performance matrix multiplication program on modern processors. In this tutorial I will use a single core of the Skylake-client CPU with AVX2, but the principles in this post also apply to other processors with different instruction sets (such as AVX512).

Intro

Matrix multiplication is a mathematical operation that defines the product of