Skip to content

Instantly share code, notes, and snippets.

View cowboymathu's full-sized avatar

Mathuvathanan Mounasamy cowboymathu

  • Randers, Denmark
View GitHub Profile
@cowboymathu
cowboymathu / 1-add-middleware.php
Created February 15, 2018 22:14 — forked from adamwathan/1-add-macros.php
Multiformat Endpoints in Laravel
<?php
namespace App\Http\Middleware;
class CaptureRequestExtension
{
public function handle($request, $next)
{
if ($request->route()->parameter('_extension') !== null) {
$request->attributes->set('_extension', substr($request->route()->parameter('_extension'), 1));
@cowboymathu
cowboymathu / touchcursor_mode.json
Created September 8, 2017 20:36
TouchCursor Karabiner-Elements json
{
"title": "TouchCursor Mode",
"rules": [
{
"description": "TouchCursor Mode [Space as Trigger Key]",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "spacebar",
<?php
// Find and replace facility for complete MySQL database
//
// Written by Mark Jackson @ MJDIGITAL
// Can be used by anyone - but give me a nod if you do!
// http://www.mjdigital.co.uk/blog
// SEARCH FOR
$search = '**__FIND_THIS__**';
function escapeAll(str) {
var hexString = "";
for (var index=0; index<str.length; index++) {
var charCode = str.charCodeAt(index);
var h = charCode.toString(16).toUpperCase();
if (h.length == 1) {
h = "0" + h;
}
h = "%" + h;
hexString += h;
@cowboymathu
cowboymathu / center-css
Created April 21, 2015 11:22
magnific-popup center css
<style>
.album-billede-box-pop {
width: 100%;
text-align: center;
}
.album-billede-single-pop {
display: inline-block;
}
</style>
@cowboymathu
cowboymathu / showImages.php
Created September 10, 2014 08:38
Show images in directory recursively
<?php
/*
Show images recursively in a directory v1.0
Author: Mathuvathanan Mounasamy
Licensed under the MIT license
*/
showImages('media/catalog/product/F');
function showImages($directory) {
@cowboymathu
cowboymathu / correctImageOrientation.php
Last active March 26, 2019 20:31
Rotate archived images to correct orientation
<?php
/*
Correct image orientation v1.0
Author: Mathuvathanan Mounasamy
Licensed under the MIT license
This funtion correct all the images' orientation in a given path or directory.
@cowboymathu
cowboymathu / count_array.rb
Created October 25, 2011 06:03
Count array elements
arr = [1,2,3,4,5,3,4,5,2,3,3,4]
arr.inject(Hash.new(0)) { |h, e| h[e] += 1 ; h }
@cowboymathu
cowboymathu / user_role_association.rb
Created October 20, 2011 05:55
Factory girl association
Factory.define :user_with_role, :parent => :user do |user|
user.after_create { |p| Factory(:role, :users => [p]) }
end
@cowboymathu
cowboymathu / qtip-ajax-demo.js
Created October 12, 2011 05:34
qTip Ajax demo sample
<script class="example" type="text/javascript">
// Create the tooltips only on document load
$(document).ready(function()
{
// Make sure to only match links to wikipedia with a rel tag
$('a[href*=wikipedia.org/][rel]').each(function()
{
// We make use of the .each() loop to gain access to each element via the "this" keyword...
$(this).qtip(
{