Skip to content

Instantly share code, notes, and snippets.

View Stringsaeed's full-sized avatar
🏗️
building something that matters

Muhammad Saeed Stringsaeed

🏗️
building something that matters
View GitHub Profile
@zbuc
zbuc / multithreaded_flask.py
Created February 18, 2015 05:38
Example Multithreaded Flask App
from flask import Flask
app = Flask("proxapp")
@app.route('/')
def hello_world():
return 'Hello World!'
@nealrs
nealrs / contractions.py
Created May 31, 2015 01:33
Expand common (and some very uncommon) english contractions
"""
this code is not mine! i shamelessly copied it from http://stackoverflow.com/questions/19790188/expanding-english-language-contractions-in-python
all credits go to alko and arturomp @ stack overflow.
basically, it's a big find/replace.
"""
import re
cList = {
"ain't": "am not",
@mdsrosa
mdsrosa / dijkstra.py
Created November 21, 2015 04:36
Modified Python implementation of Dijkstra's Algorithm (https://gist.github.com/econchick/4666413)
from collections import defaultdict, deque
class Graph(object):
def __init__(self):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
def add_node(self, value):
@sagivo
sagivo / gist:3a4b2f2c7ac6e1b5267c2f1f59ac6c6b
Last active May 3, 2024 10:41
webRTC stun / turn server list
to check if the server works - https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice
stun:
stun.l.google.com:19302,
stun1.l.google.com:19302,
stun2.l.google.com:19302,
stun3.l.google.com:19302,
stun4.l.google.com:19302,
stun.ekiga.net,
stun.ideasip.com,
@mreigen
mreigen / generate-alphabets.js
Created November 20, 2017 05:55
Javascript generate alphabet string
function generateAlphabets() {
var alphabets = [];
var start = 'A'.charCodeAt(0);
var last = 'Z'.charCodeAt(0);
for (var i = start; i <= last; ++i) {
alphabets.push(String.fromCharCode(i));
}
return alphabets.join('');
}
@necolas
necolas / AppText.js
Last active April 17, 2022 19:13
Localized typography with React Native
import i18n from './i18n';
import theme from './theme';
import { bool, string } from 'prop-types';
import { I18nManager, StyleSheet, Text } from 'react-native';
import React, { Component } from 'react';
/**
* React Component
*/
class AppText extends Component {
@infinityfuture
infinityfuture / textrank_keywords.py
Last active February 15, 2019 16:01
TextRank extract keywords
"""
Reference:
http://www.hankcs.com/nlp/textrank-algorithm-to-extract-the-keywords-java-implementation.html
http://www.hankcs.com/nlp/textrank-algorithm-java-implementation-of-automatic-abstract.html
"""
import numpy as np
@andywer
andywer / _readme.md
Last active March 7, 2024 05:52
React - Functional error boundaries

React - Functional error boundaries

Thanks to React hooks you have now happily turned all your classes into functional components.

Wait, all your components? Not quite. There is one thing that can still only be implemented using classes: Error boundaries.

There is just no functional equivalent for componentDidCatch and deriveStateFromError yet.

Proposed solution

import * as React from 'react';
import { padStart, eq, isEqual } from 'lodash';
export function useDebugDeps(name: string, deps: unknown[]): void {
const previousDepsRef = React.useRef(deps);
const countRef = React.useRef(0);
printDepsChange(name, deps, previousDepsRef.current, countRef.current);
previousDepsRef.current = deps;
@intergalacticspacehighway
intergalacticspacehighway / PinchToZoom.tsx
Last active April 23, 2024 20:16
Pinch to zoom reanimated + gesture handler
import React, { useMemo, useState } from "react";
import { LayoutChangeEvent, StyleSheet } from "react-native";
import {
PinchGestureHandler,
PinchGestureHandlerGestureEvent,
} from "react-native-gesture-handler";
import Animated, {
useAnimatedGestureHandler,
useAnimatedStyle,
useSharedValue,