Skip to content

Instantly share code, notes, and snippets.

View tmkasun's full-sized avatar
🕶️

Kasun Thennakoon tmkasun

🕶️
View GitHub Profile
@sebmarkbage
sebmarkbage / The Rules.md
Last active April 15, 2024 16:24
The Rules of React

The Rules of React

All libraries have subtle rules that you have to follow for them to work well. Often these are implied and undocumented rules that you have to learn as you go. This is an attempt to document the rules of React renders. Ideally a type system could enforce it.

What Functions Are "Pure"?

A number of methods in React are assumed to be "pure".

On classes that's the constructor, getDerivedStateFromProps, shouldComponentUpdate and render.

@Beneboe
Beneboe / how-to-setup-verified-commits.md
Last active March 20, 2024 18:20
How to Setup Verified Commits on Github
@benkulbertis
benkulbertis / cloudflare-update-record.sh
Last active March 4, 2024 11:27
Cloudflare API v4 Dynamic DNS Update in Bash
#!/bin/bash
# CHANGE THESE
auth_email="user@example.com"
auth_key="c2547eb745079dac9320b638f5e225cf483cc5cfdda41" # found in cloudflare account settings
zone_name="example.com"
record_name="www.example.com"
# MAYBE CHANGE THESE
ip=$(curl -s http://ipv4.icanhazip.com)
@volkancakil
volkancakil / instGlobal.sh
Last active October 12, 2022 14:59
How to install GNU Global 6.5.6 on Ubuntu 16.10
#!/bin/bash
# instGlobal.sh
echo "instGlobal.sh ...."
echo "install package for GNU global..."
sudo apt-get update
sudo apt-get -y install curl
sudo apt-get -y install wget
sudo apt-get -y install ncurses-dev
@rozifus
rozifus / Python SimpleHTTPServer with SSL
Last active October 9, 2022 22:40
Python SimpleHTTPServer with SSL
# useful for running ssl server on localhost
# which in turn is useful for working with WebSocket Secure (wss)
# copied from http://www.piware.de/2011/01/creating-an-https-server-in-python/
@debasishg
debasishg / gist:b4df1648d3f1776abdff
Last active January 20, 2021 12:15
another attempt to organize my ML readings ..
  1. Feature Learning
  1. Deep Learning
@amueller
amueller / mlp.py
Created March 17, 2012 15:59
Multi-Layer Perceptron for scikit-learn with SGD in Python
import numpy as np
import warnings
from itertools import cycle, izip
from sklearn.utils import gen_even_slices
from sklearn.utils import shuffle
from sklearn.base import BaseEstimator
from sklearn.base import ClassifierMixin
from sklearn.preprocessing import LabelBinarizer
@tmkasun
tmkasun / dev_mode.sh
Last active October 17, 2019 09:02
Setup APIM server and Run it with it's depending servers, Will only be useful until API manager product properly pack the dependencies in to final product. Till we get there ...
#! /usr/bin/env bash
# HOW TO USE: Put this file inside the directory where you would like to extract and run the product-APIM build file (.zip file)
# Change the below path variables accordingly *** NOTE: No trailing `/` slashes has been used
# This will only work with APIM 3.0.0 latest version with Carbon 4.x kernel. Addition to coping and unziping the pack,
# This script will only create symbolic links to the carbon-apimgt repository files.
source_path="/Users/tmkasun/Documents/wso2/dev/products/apim/carbon-apimgt-forked/features/apimgt"
product_apimgt_path="/Users/tmkasun/Documents/wso2/dev/products/apim/product-apim-forked"
pack_name="wso2am-3.0.0-SNAPSHOT"
action=$1
@lukemarsden
lukemarsden / httpRequest.py
Created February 27, 2011 21:11
Simple function to do an HTTP POST using Twisted Agent
from twisted.web.iweb import IBodyProducer
from twisted.internet import defer
from twisted.web.client import Agent
from twisted.web.http_headers import Headers
import urllib
class StringProducer(object):
implements(IBodyProducer)
def __init__(self, body):
@creativeaura
creativeaura / server.py
Created May 9, 2013 10:34
Modifying Python's SimpleHTTPServer to accept directory aliases
import os
import posixpath
import urllib
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
# modify this to add additional routes
ROUTES = (
# [url_prefix , directory_path]
['/media', '/var/www/media'],