Skip to content

Instantly share code, notes, and snippets.

View oshanz's full-sized avatar
🌴
On vacation

Oshan Wisumperuma oshanz

🌴
On vacation
View GitHub Profile
var product_Name_id = $j('#product_Name_1 option:selected').attr("id");
var product_Name = $j('#product_Name_1 option:selected').text();
@oshanz
oshanz / check
Created March 10, 2014 09:21
radio
$('input:checkbox').prop('checked', false);
$("input[name=type]:checked").val()
$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'));
@oshanz
oshanz / basic chat
Created March 28, 2014 04:30
Socket
<?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 August 29, 2015 13:58
Convert Numbers to Words
PHP or Javascript
@oshanz
oshanz / PHP – Google Currency Converter
Created April 9, 2014 10:28
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 August 29, 2015 14:02
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
@oshanz
oshanz / web_worker
Created June 23, 2014 03:59
observer
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 August 29, 2015 14:03
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 August 29, 2015 14:04
javascript table Expand row
(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();