Skip to content

Instantly share code, notes, and snippets.

View mahasak's full-sized avatar
🐻
PapaBear online !!

Max Pijittum mahasak

🐻
PapaBear online !!
View GitHub Profile
var user = {
validateCredentials: function (username, password) {
return (
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' }
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' }
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' }
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' }
: (!/^([a-z0-9_-]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' }
: false
);
@mahasak
mahasak / gist:f8f167327180298921d1
Last active August 29, 2015 14:21
Install Ubuntu + Python + Nginx + uWSGI
Fix locale problem
------------------------------------------
Run the following command
$ update-locale LC_ALL="en_US.UTF-8"
If it failed, you will need to add the following to __/var/lib/locales/supported.d/local__ file
en_US.UTF-8 UTF-8
@mahasak
mahasak / TwoSum.scala
Last active August 29, 2015 14:21 — forked from nuboat/TwoSum.scala
object TwoSum {
def sum(n: Int, sorted: ArrayBuffer[Int]): Boolean = sorted.par.find(x => isMatch(x, n, sorted)).isDefined
def isMatch(x: Int, n: Int, sorted: ArrayBuffer[Int]): Boolean = sorted.find( y => (x + y) == n).isDefined
}
import re
import shutil
import argparse
from os import path
from sys import stderr
#
# Author: Daxda
# Date: 02.04.2014
# WTF: This is a quick tool I've hacked together to easily remove the meta
#/bin/env/python
#Author : Psycho_Coder
#Date : 7/11/2014
import os
import sys
import binascii
hex_link_pat = "".join("0A 2F 42 6F 72 64 65 72 20 5B 20 30 20 30 20 30 20 5D "
"0A 2F 41 20 3C 3C 0A 2F 54 79 70 65 20 2F 41 63 74 69 "
@mahasak
mahasak / remove_txt
Last active August 29, 2015 14:23 — forked from bikz05/remove_txt
echo $"Script Written by $(tput setaf 5)Bikram Hanzra$(tput sgr 0) (bikz.05@gmail.com)"$
if [ "$#" == 0 ] ; then
echo "$(tput setaf 1)We need at least 2 arguments"
echo "SYNTAX ./remove <file-name> <text-to-be-removed>"
echo "<text-to-be-removed> by default = www.it-ebooks.info$(tput sgr 0)"
exit
fi
if [ "$#" == 1 ] ; then
dnvm use default -r coreclr && dnu build --framework dnxcore50
or
dnvm use default -r mono && dnu build
#Get Hostname
$env:computername
(Get-WmiObject -Class Win32_ComputerSystem -Property Name).Name
#Define Common Name
$cname = "CN=MyTestServer"
#Generate Self-Sign Certificate for IIS
makecert -r -pe -n $cname -b 01/01/2016 -e 01/01/2017 -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localMachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12
#!/bin/bash
# xvfb - this script starts and stops Xvfb for using with Selenium Grid
#
# chkconfig: 345 95 50
# description: Starts Xvfb on display 99
# processname: Xvfb
# pidfile: /var/log/Xvfb/Xvfb.pid
#
# Place this script as /etc/init.d/xvfb and chmod +x /etc/init.d/xvfb
@mahasak
mahasak / jstatd
Created May 17, 2016 11:57 — forked from warmans/gist:03e8ebd178b5e94fd7c7
Centos jstatd init script
#!/bin/sh
# jstatd - runs the jstat daemon
#
# chkconfig: - 85 15
# description: Jstatd JVM monitoring
# processname: jstatd
# pidfile: /var/run/jstatd.pid
# Source function library.
. /etc/rc.d/init.d/functions