Skip to content

Instantly share code, notes, and snippets.

View ismnoiet's full-sized avatar

ismnoiet

  • Planet Earth
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<title>training camp etic 2016</title>
<!-- inlude style file -->
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<?php
// Create a pdo instance
$host = 'localhost';
$database_name = 'databasename';
$username='username by default it is root';
$password='the password associated with the current user';
try{
// check if there is exception
$pdo = new PDO("mysql:host=$host;dbname=$database_name","$username","$password");
window.validator = {
tel:/^0[0-9]{8,9}$/,
fax:/^0[0-9]{8}$/,
mob:/^0[0-9]{9}$/,
username:/^[a-z0-9_-]{3,16}$/,
name:/^[a-z ]+$/,
email:/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/,
url:/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w\.\-&\?=]*)*\/?$/,
anything:/.+?$/,
test:function(type,str){
@ismnoiet
ismnoiet / write-append-file.js
Created March 14, 2016 08:58 — forked from umidjons/write-append-file.js
NodeJS: Write/Append into a file
var f='write.txt',
fs=require('fs');
fs.writeFile(f,'Some text to write.',function(err){
if(err)
console.error(err);
console.log('Written!');
});
fs.appendFile(f,'Some more text to append.',function(err){
@ismnoiet
ismnoiet / date_to_french_format.php
Last active March 25, 2016 10:13
Convert date to french format in PHP without using locals
<?php
function to_french_format($date){
$date = date("l d/m/Y h:i", strtotime($date));
$date_components = split(' ',$date);
$french_days = array(
'Saturday'=>'Samedi',
'Sundy'=>'Dimanche',
'Monday'=>'Lundi',
'Tuesday'=>'Mardi',
//first.js
var util = require('util'),
EventEmitter = require('events');
function First () {
EventEmitter.call(this)
}
util.inherits(First, EventEmitter);
@ismnoiet
ismnoiet / index.js
Created April 7, 2016 13:17
requirebin sketch
var markdown = require( "markdown" ).markdown;
var markdownStr = ['#Hello World','somethig else','#another title'].join("\n");
var htmlResult= markdown.toHTML(markdownStr);
var finalResult = htmlResult.replace(/<h1>/g,'<h3>');
finalResult.replace(/<\/h1>/g,'</h3>');
@ismnoiet
ismnoiet / sublime.sublime-project
Created May 4, 2016 09:05
Set up Sublime text 3 to ignore "bower_components" & "node_modules" folders while searching for words.
{
"folders":
[
{
"path": ".",
"follow_symlinks": true,
"folder_exclude_patterns": ["bower_components", "node_modules"]
}
]
}
// A function for creating a new object that inherits from another
// method1:
// naked function to be used as a constructor
var Ctor = function(){};
function cloneObj(srcObj){
Ctor.prototype = srcObj;
var clone = new Ctor();
Ctor.prototype = null;