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
@gayanhewa
gayanhewa / config.xml
Created September 19, 2012 04:49
Magent extention : Working config.xml file with custom table
<config>
<modules>
<Sample_Socialmedia>
<version>0.0.1</version>
</Sample_Socialmedia>
</modules>
<frontend>
<routers>
<socailpromo>
<use>standard</use>
@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()
@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(
@macmladen
macmladen / bash-one-liners.sh
Last active October 7, 2016 18:19
BASH one-liners
## CHECKING HEADERS AND CERTIFICATE
# curl headers
curl -Iv https://example.com
# check certificate
openssl s_client -connect www.example.com:443
## FIXING FILES PERMISSIONS
# Remove Mac OS X Desktop Services Store files
find . -name ".DS_Store" -exec rm {} \;
# If you accidentally chmod -R 755 on everything revert files to 644
@xeoncross
xeoncross / feistel.php
Created September 13, 2012 16:05 — forked from baldurrensch/feistel.php
Feistel Hash
<?php
/**
* This function computes a hash of an integer. This can be used to not expose values to a customer, such as
* not giving them the id value for passing them to URLs. This algorithm is a bidirectional encryption (Feistel cipher) that maps
* the integer space onto itself.
*
* @link http://wiki.postgresql.org/wiki/Pseudo_encrypt Algorithm used
* @link http://en.wikipedia.org/wiki/Feistel_cipher Wikipedia page about Feistel ciphers
* @param int $value
* @return int
@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.
@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";
@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
@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';