Skip to content

def co_dumps(f):
import base64, cPickle
co = f.func_code
ss = [[co.co_argcount,co.co_nlocals, co.co_stacksize,co.co_flags,
co.co_code,co.co_consts,co.co_names,co.co_varnames,co.co_filename,
co.co_name,co.co_firstlineno,co.co_lnotab], None, f.func_name, f.func_defaults, f.func_closure]
return base64.urlsafe_b64encode(cPickle.dumps(ss))
def ch(x):
if x > 10:
@juyal-ahmed
juyal-ahmed / haversine.sql
Last active November 30, 2015 10:07
Haversine Distance Computation with MySQL
SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( latitude ) ) * cos( radians( longitude ) -
radians(-122) ) + sin( radians(37) ) * sin(radians(latitude)) ) ) AS distance FROM dispensaries
HAVING distance < 25 ORDER BY distance LIMIT 0 , 20

#React Components

In general, there are 2 ways to create React Component.

1.0 Class Component

Here an extension of react component, we can do all sort of things, but for class component, it always going need to render(), to return a component.

Note, this component will can have state.

Flavor 1: JSX

@JordanPak
JordanPak / functions.php
Created November 30, 2015 20:42
Genesis Home Intro
// Register Home Intro Widget Area
genesis_register_sidebar( array(
'id' => 'home-intro',
'name' => __( 'Home Intro', 'jordanpak' ),
'description' => __( '"Featured Section" at the top of the home page.', 'jordanpak' ),
'before_widget' => '<div class="widget-area home-intro">',
'after_widget' => '</div>'
) );
@atsakiridis
atsakiridis / restcomm-server.log
Created November 30, 2015 15:46
Issues with staging.restcomm.com
15:43:13,367 INFO [gov.nist.javax.sip.stack.UDPMessageChannel] (Mobicents-SIP-Servlets-UDPMessageChannelThread-466) Setting SIPMessage peerPacketSource to: /79.167.144.228:5080
15:43:13,368 INFO [gov.nist.javax.sip.stack.SIPTransactionStack] (Mobicents-SIP-Servlets-UDPMessageChannelThread-466) <message
from="79.167.144.228:5080"
to="172.17.0.68:5060"
time="1448898193366"
isSender="false"
transactionId="z9hg4bk-373831-7c18573aaba279fa8a24305430c9f788"
callId="8d88183f92bc3a3620ce3656336184ca@192.168.2.41"
firstLine="INVITE sip:alice-sdk@staging.restcomm.com SIP/2.0"
>
class ZCL_PACK_OBJECT definition
public
abstract
final
create public .
public section.
class-methods UNPACKING_OBJECT
importing
@mdauphin
mdauphin / extract_table.py
Created November 30, 2015 10:09
Extract table from MySQL dump gz compressed file
import sys
import gzip
'''
Extract table from MySQL dump file
use like this:
python extract_table.py filename.gz table_name > extract.txt
'''
with gzip.open(sys.argv[1],'rb') as f:
For those who has problems with OpenSSL::SSL::SSLError SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed on your machine:
rvm remove 2.1.5
brew install openssl
rvm install 2.1.5 --with-openssl-dir=`brew --prefix openssl`
@chon1034
chon1034 / ar02.c
Last active April 15, 2019 01:53
midterm2
#include <stdio.h>
#include <stdlib.h>
//多項式
int mult(int a[],int na, int b[],int nb, int c[])
{
int i,j;
for(i=0;i<=na+nb;i++){
c[i]=0;
}
@rbg246
rbg246 / check-for-google-analytics-id.js
Created November 30, 2015 09:28
Prints a list of universal analytic ids found on a site
function checkAnalytics () {
var ids = ga.getAll();
var len = ids.length;
console.log('Universal Analytics');
console.log('ids', ids);
console.log('=======================================================');
console.log('Number of Universal Analytics IDs found : ' + ids.length);
console.log('=======================================================');
console.log('Universal Analytics IDs');
console.log('=======================================================');