Skip to content

Instantly share code, notes, and snippets.

View umanda's full-sized avatar
🎯
Focusing

Umanda Jayobandara umanda

🎯
Focusing
View GitHub Profile
@umanda
umanda / 1. Multiple user type for Laravel 4.md
Last active November 19, 2019 20:08
Multiple user type for Laravel 4.2 and Sentry 2.

Recently I wanted to have a system with multiple user loggings with Laravel and Sentry 2. I was searched over the internet and I found a nice solution from leabdalla.

https://gist.github.com/leabdalla/5999421

Unfortunately this solution is working only Laravel 4.0 and Sentry 2. I have noted leabdalla post his GITS in 2013 and meantime laravel and Sentry has some updates. Therefor leabdalla’s code not working with latest Laravel and Sentry releases.

I have fixed that issue and my changes are compatible with Latest Laravel releases. As well as this might be not work with future changes in laravel as well as sentry

@umanda
umanda / 0_reuse_code.js
Last active August 29, 2015 14:13
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@umanda
umanda / unicode-detector.html
Last active August 29, 2015 14:13
Sinhala and English text detector
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Unicode detector</title>
<script>
function myFunction() {
var x = document.getElementById("frm1");
var data = "";
data = x.elements[0].value;
@umanda
umanda / Illegal-string-offset-Warning-PHP.php
Created February 16, 2015 11:22
Illegal string offset Warning PHP
function isset_get($array, $key, $default = null) {
return isset($array[$key]) ? $array[$key] : $default;
}
$myVar = isset_get($someArray, 'someKey');
//or with some default if you got one
$myVar = isset_get($someArray, 'someKey', $mydefault);
@umanda
umanda / user-extension.js
Created February 24, 2015 05:43
Custom function for selenium IDE. For install Option > Options > Add js path in Selenium core extension location To get selenium IDE Selenium IDE is only work for Firefox http://docs.seleniumhq.org/download/
var gotoLabels= {};
var whileLabels = {};
Selenium.prototype.reset = function() {
this.initialiseLabels();
this.defaultTimeout = Selenium.DEFAULT_TIMEOUT;
this.browserbot.selectWindow("null");
this.browserbot.resetPopups();
}
@umanda
umanda / HelloTest.php
Last active August 29, 2015 14:16
Set up PHPUnit in Windows + XAMPP + Eclips
<?php
class HelloTest extends \PHPUnit_Framework_TestCase {
public function testTrueIsTrue()
{
$foo = true;
$foo2 = false;
$this->assertTrue($foo);
$this->assertFalse($foo2);
}
}
@umanda
umanda / json_validate.php
Created March 23, 2015 10:33
Validate JSON String in PHP
/**
* Validate JSON String
* @param String $json
* @return boolean
*/
protected function isValidJson($json) {
json_decode($json);
return (json_last_error() == JSON_ERROR_NONE);
}
@umanda
umanda / demo.html
Last active August 29, 2015 14:20
Change the order of col-*-12 columns in Bootstrap 3 by using push/pull
<div class="row reorder-xs">
<div class="col-xs-12">
<p>test1</p>
</div>
<div class="col-xs-12">
<p>test2</p>
</div>
</div>
@umanda
umanda / get_row.sql
Last active September 2, 2015 09:47
How to Query the DB for your form data
SELECT DATE_FORMAT( FROM_UNIXTIME( submit_time ) , '%b %e, %Y %l:%i %p' ) AS Submitted,
MAX ( IF( field_name = 'your-name', field_value, NULL ) ) AS 'Name',
MAX ( IF( field_name = 'your-message', field_value, NULL ) ) AS 'CardNum'
FROM wp_cf7dbplugin_submits
WHERE form_name = 'suggestion form'
GROUP BY submit_time
ORDER BY submit_time DESC
LIMIT 0 , 30
@umanda
umanda / bs3_tab_select.js
Created July 7, 2015 08:10
Twitter Bootstrap Tabs: Go to Specific Tab on Page Reload or Hyperlink
// Javascript to enable link to tab
var url = document.location.toString();
if (url.match('#')) {
$('.nav-tabs a[href=#'+url.split('#')[1]+']').tab('show') ;
}
// Change hash for page-reload
$('.nav-tabs a').on('shown.bs.tab', function (e) {
window.location.hash = e.target.hash;
})