Skip to content

Instantly share code, notes, and snippets.

@shandanjay
shandanjay / sl_mobile_num.php
Last active January 21, 2021 04:51
Sri Lanka Mobile number validation in PHP
<?php
$a = '+94715753168';
$b = '0715753168';
$c = '715753168';
$d = '0094715753168';
$e = '094-71-5-753-168';
is_lk_mobile($a); //true
is_lk_mobile($b); //true
is_lk_mobile($c); //true
@shandanjay
shandanjay / regex.php
Last active November 29, 2017 13:15
Sri Lanka Vehicle plate number RegEx
<?php
$valid = '64-8681'; // BAC-1488
$invalid = '00-8681'; // A1C-3422
$re = '/^([a-zA-Z]{1,3}|((?!0*-)[0-9]{1,3}))-[0-9]{4}(?<!0{4})/m';
echo preg_match($re, $valid); //true
@shandanjay
shandanjay / core.clj
Created July 11, 2016 06:31 — forked from nikolaplejic/core.clj
File upload example in Compojure
(ns fileupload.core
(:use [net.cgrand.enlive-html
:only [deftemplate defsnippet content clone-for
nth-of-type first-child do-> set-attr sniptest at emit*]]
[compojure.core]
[ring.adapter.jetty])
(:require (compojure [route :as route])
(ring.util [response :as response])
(ring.middleware [multipart-params :as mp])
(clojure.contrib [duck-streams :as ds]))
@shandanjay
shandanjay / chmodr.sh
Created May 21, 2016 01:28 — forked from francisbyrne/chmodr.sh
Recursive chmod script for dirs and/or files
#!/bin/sh
#
# chmodr.sh
#
# author: Francis Byrne
# date: 2011/02/12
#
# Generic Script for recursively setting permissions for directories and files
# to defined or default permissions using chmod.
#
@shandanjay
shandanjay / slack-user-timezones.php
Created May 17, 2016 04:19 — forked from kasparsd/index.html
Get user timezones using Slack API
<?php
$api_token = 'slack-api-token';
if ( file_exists( 'users.json' ) ) {
$api_users = file_get_contents( 'users.json' );
} else {
$api_users = file_get_contents( 'https://slack.com/api/users.list?token=' . $api_token );
if ( false === $api_users ) {
@shandanjay
shandanjay / simplecart_parser.clj
Created May 3, 2016 23:31 — forked from sventech/simplecart_parser.clj
Clojure parser for SimpleCart(js) form POST/GET
(ns webstore.simplecart_parser
(:require [clojure.string :as string]))
;; see github.com/sventech/simplecart-js for tax calculation improvement fork
(def input-params
{"item_quantity_1" "1",
"itemCount" "2",
"item_price_1" "9.99",
"store_name" "Online Store",
"item_name_1" "Awesome Product - MP3",
@shandanjay
shandanjay / vhosts.pl
Last active July 19, 2019 17:48
Creating Virtual hosts in Apache under redhat linux systems (CentOS / Fedora)
#!/usr/bin/perl
#run as a super user
if (!@ARGV){
print 'usage example: #vhosts testing.localsitename.com /var/www/html/site_folder_name username' ."\n";
exit(0);
}
$url = $ARGV[0];
@shandanjay
shandanjay / pma.pl
Created May 18, 2015 06:52
Split databases from a bulk db sql file created by PhpMyAdmin. (the sql file name need to be "localhost.sql")
use Tie::File;
use IO::Handle;
tie @SQL_FILE, 'Tie::File' , "localhost.sql" or die $!;
mkdir('output');
STDOUT->printflush("Processing");
for $lineNum (1 .. $#SQL_FILE){
if($SQL_FILE[$lineNum] =~ /\-\- Database: `(.*)`/){

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})