Skip to content

Instantly share code, notes, and snippets.

View gayanhewa's full-sized avatar
🦧
I may be slow to respond.

Gayan gayanhewa

🦧
I may be slow to respond.
View GitHub Profile
@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active April 7, 2024 22:55
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@rajkrrsingh
rajkrrsingh / Google protobuf installation on Mac
Created November 27, 2016 10:57
Steps to Install google protobuf on Mac
$wget https://github.com/google/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.bz2
$tar xvf protobuf-2.5.0.tar.bz2
$cd protobuf-2.5.0
$./configure CC=clang CXX=clang++ CXXFLAGS='-std=c++11 -stdlib=libc++ -O3 -g' LDFLAGS='-stdlib=libc++' LIBS="-lc++ -lc++abi"
$make -j 4
$sudo make install
$protoc --version
@steverobbins
steverobbins / 00-magento-session-db-gc-non-locking-readme.md
Last active January 18, 2021 05:18
Clean Magento's core_session table in background

Script to "safely" clean up the core_session table without causing lock wait timeouts.

Not thoroughly vetted but met the client's needs.

Requires disabling Mage_Core_Model_Resource_Session:gc(), e.g.

--- a/app/code/core/Mage/Core/Model/Resource/Session.php
+++ b/app/code/core/Mage/Core/Model/Resource/Session.php
@@ -74,7 +74,7 @@ class Mage_Core_Model_Resource_Session implements Zend_Session_SaveHandler_Inter
@RadGH
RadGH / short-number-format.php
Last active April 9, 2024 11:28
Short Number Formatter for PHP (1000 to 1k; 1m; 1b; 1t)
<?php
// Converts a number into a short version, eg: 1000 -> 1k
// Based on: http://stackoverflow.com/a/4371114
function number_format_short( $n, $precision = 1 ) {
if ($n < 900) {
// 0 - 900
$n_format = number_format($n, $precision);
$suffix = '';
} else if ($n < 900000) {
@gayanhewa
gayanhewa / signature.php
Created September 24, 2014 04:25
HMAC + Sha256 hashed API Auth - This snippet implements the logic behing https://github.com/philipbrown/signplz
<?php
/**
* This snippet implements the logic behing https://github.com/philipbrown/signplz , simply to explain the functionality of generating the auth signature
* for non-php programmers so that they can authenticate with the API without a problem.
**/
$api_key = "key";
$api_sec = "sec";
$url = "http://abc.com/api/test";
@dirx
dirx / gist:60414eb80da9c7dbfb19
Last active January 17, 2017 03:44
Convert multiple array() to new php 5.4 style [] in code with phpstorm
Search regexp: \barray\(([^\(]*?)\)
Replace with: [$1]
Search & replace until it´s done.
Does not work if ( is in array keys or values.
@jeremeamia
jeremeamia / config.php
Last active March 26, 2016 11:36
Mini-PHP config system for fun. (MIT Licensed)
<?php
namespace config;
const DELIM = '.';
/**
* Loads a configuration array from a file, based on it's type.
*
* @param string $path
@tbrianjones
tbrianjones / sqs_web_manager.php
Last active August 1, 2016 20:22
A Simple Web App to manage Amazon SQS Queues ... delete/clear ... and add items to the queues ... all via web forms.
<?php
// include api config file
require_once( dirname( __FILE__ ) . '/../../config.php' );
// create aws sqs conneciton
require_once( BASE_PATH . 'libraries/aws_php_sdk_v2/vendor/autoload.php' );
use Aws\Sqs\SqsClient;
try {
$config = array(
http://stackoverflow.com/questions/19386962/laravel-eloquent-and-complex-relationships?rq=1
http://forumsarchive.laravel.io/viewtopic.php?pid=21255
http://stackoverflow.com/questions/20666490/laravel-4-mssql-stored-procedure-with-parameters-as-a-prepared-statements
http://culttt.com/2013/08/05/extending-eloquent-in-laravel-4/
http://www.blogosfera.co.uk/2013/08/pass-parameters-in-insert-query-stored-procedure-in-laravel-4/
@kbirmhrjn
kbirmhrjn / TestCase.php
Created January 6, 2014 07:55
TestCase
<?php
class TestCase extends Illuminate\Foundation\Testing\TestCase {
/**
* Creates the application.
*
* @return Symfony\Component\HttpKernel\HttpKernelInterface
*/
public function createApplication()