Skip to content

Instantly share code, notes, and snippets.

🐳
Working from home

Oshan Wisumperuma oshanz

🐳
Working from home
Block or report user

Report or block oshanz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:9482754
$from = $_GET['from'] . '-01';
$to = $_GET['to'];
$date = date_create_from_format('Y-m', $to);
$to = $to . '-' . cal_days_in_month(CAL_GREGORIAN, $date->format('m'), $date->format('Y'));
View basic chat
<?php
error_reporting(~E_NOTICE);
set_time_limit(0);
$address = "192.168.1.60";
$port = 5000;
$max_clients = 10;
if (!($sock = socket_create(AF_INET, SOCK_STREAM, 0))) {
@oshanz
oshanz / Convert Numbers to Words
Last active Aug 29, 2015
Convert Numbers to Words
@oshanz
oshanz / PHP – Google Currency Converter
Created Apr 9, 2014
PHP – Google Currency Converter
View PHP – Google Currency Converter
<?php
function currency_convert($from,$to,$amount) {
$string = "1".$from."=?".$to;
$google_url = "http://www.google.com/ig/calculator?hl=en&q=".$string;
$result = file_get_contents($google_url);
$result = explode('"', $result);
$converted_amount = explode(' ', $result[3]);
$conversion = $converted_amount[0];
$conversion = $conversion * $amount;
$conversion = round($conversion, 2);
@oshanz
oshanz / Multisearch
Last active Aug 29, 2015
Multisearch
View Multisearch
<?php
/**
* @author Waruna Oshan Wisumperuma
* @contact warunaoshan@gmail.com
*
* https://gist.github.com/oshanz/97782c79ac186c5f6e59
* Semantic version = 1.0.0
*
* This program is free software: you can redistribute it and/or modify
View web_worker
var worker = new Worker(URL + "view/gmapsRoute/js/observer.js");
worker.postMessage("sdfdf");
worker.onmessage = function(event) {
alert("Received message " + event.data);
worker.terminate();
};
*************************************************************************************
@oshanz
oshanz / getScript More
Last active Aug 29, 2015
getScript More
View getScript More
function loadOrdered(files, callback) {
$.getScript(files.shift(), function() {
files.length
? loadOrdered(files, callback)
: callback();
});
}
edit, a nicer version:
function loadOrdered(files, callback) {
@oshanz
oshanz / jexpand
Last active Aug 29, 2015
javascript table Expand row
View jexpand
(function($){
$.fn.jExpand = function(){
var element = this;
$(element).find("tr:odd").addClass("odd");
$(element).find("tr:not(.odd)").hide();
$(element).find("tr:first-child").show();
$(element).find("tr.odd").click(function() {
$(this).next("tr").toggle();
View sql get dates in list
select
selected_date
from
(select
adddate('2014-02-10', t4.i * 10000 + t3.i * 1000 + t2.i * 100 + t1.i * 10 + t0.i) selected_date
from
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t0, (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t1, (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2, (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3, (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v
where
selected_date between '2014-02-10' and '2014-02-15'
@oshanz
oshanz / list
Created Oct 2, 2014
Get a list of dates between two dates using javascript
View list
function generateDateList(from, to) {
var getDate = function(date) {//Mysql Format
var m = 1 + date.getMonth(), d = date.getDate();
return date.getFullYear() + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d);
}
var fs = from.split('-'), startDate = new Date(fs[0], parseInt(fs[1]) - 1, fs[2]), result = [getDate(startDate)], start = startDate.getTime(), ts, end;
if ( typeof to == 'undefined') {
end = new Date().getTime();
} else {
You can’t perform that action at this time.