Skip to content

Instantly share code, notes, and snippets.

View giriannamalai's full-sized avatar
🪲
Catching

Giri Annamalai M giriannamalai

🪲
Catching
View GitHub Profile
@nicksantamaria
nicksantamaria / fork-example.php
Created October 20, 2016 22:35
Example: Parallel processing in PHP using pcntl_fork()
<?php
/**
* @file
* Basic demonstration of how to do parallel threads in PHP.
*/
// This array of "tasks" could be anything. For demonstration purposes
// these are just strings, but they could be a callback, class or
// include file (hell, even code-as-a-string to pass to eval()).
@bgusach
bgusach / multireplace.py
Last active February 16, 2024 02:52
Python string multireplacement
def multireplace(string, replacements, ignore_case=False):
"""
Given a string and a replacement map, it returns the replaced string.
:param str string: string to execute replacements on
:param dict replacements: replacement dictionary {value to find: value to replace}
:param bool ignore_case: whether the match should be case insensitive
:rtype: str
"""
@cadrev
cadrev / pandas_shuffle.py
Last active August 22, 2020 08:40
Shuffle the rows of a python pandas dataframe
'''
Title : Pandas Row Shuffler
Author : Felan Carlo Garcia
'''
import numpy as np
import pandas as pd
def shuffler(filename):
df = pd.read_csv(filename, header=0)
# return the pandas dataframe
@phindmarsh
phindmarsh / composer.json
Last active March 16, 2019 14:46
Composer Install Verbose Output
{
"name": "phindmarsh/composer-test",
"description": "Testcase for checking dependencies bug",
"require": {
"silex/silex": "dev-master#279c773342c6c4d141ebd5236b18518c96505e00"
},
"authors": [
{
"name": "Patrick Hindmarsh",
"email": "patrick@hindmar.sh"
@sebmarkbage
sebmarkbage / Enhance.js
Last active January 31, 2024 18:33
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@ranacseruet
ranacseruet / VideoStream.php
Last active April 14, 2024 12:42
PHP VideoStream class for HTML5 video streaming
<?php
/**
* Description of VideoStream
*
* @author Rana
* @link http://codesamplez.com/programming/php-html5-video-streaming-tutorial
*/
class VideoStream
{
private $path = "";
@banrahan
banrahan / R.sublime-build
Created July 31, 2013 09:12
R build system for Sublime Text 3
{
"cmd": ["/usr/local/bin/Rscript", "$file"],
"selector": "source.r"
}
@6174
6174 / Random-string
Created July 23, 2013 13:36
Generate a random string in JavaScript In a short and fast way!
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
@msurguy
msurguy / eloquent.md
Last active February 8, 2022 03:13
Laravel 4 Eloquent Cheat Sheet.

Conventions:

Defining Eloquent model (will assume that DB table named is set as plural of class name and primary key named "id"):

class Shop extends Eloquent {}

Using custom table name

protected $table = 'my_shops';

@sagar-ganatra
sagar-ganatra / localStorage.html
Created October 10, 2012 10:28
Local storage event listeners
<!DOCTYPE html>
<html>
<head>
<title>localStorage Test</title>
<script type="text/javascript" >
var count = 0;
var storageHandler = function () {
alert('storage event 1');
};