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
);
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
@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
@mahasak
mahasak / nginx.conf
Created July 2, 2016 17:29 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@mahasak
mahasak / virtualbox_vagrant_home.bat
Created July 13, 2016 16:36 — forked from michaelklapper/virtualbox_vagrant_home.bat
Reconfigure VirtualBox and Vagrant home directory for Windows Set VirtualBox home directory to: C:\VMs Store vagrant boxes: C:\VMs\vagrant.d
# VirtualBox home directory.
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" setproperty machinefolder "C:\VMs"
# Vagrant home directory for downloadad boxes.
REG ADD HKCU\Environment /v VAGRANT_HOME /t REG_SZ /d "C:\VMs\vagrant.d"
@mahasak
mahasak / 1_Dockerised_JMeter.md
Last active August 7, 2016 16:06 — forked from hhcordero/1_Dockerised_JMeter.md
Dockerized JMeter - A Distributed Load Testing Workflow
@mahasak
mahasak / Feature.cs
Created March 16, 2017 17:20 — forked from pseudomuto/Feature.cs
Blog Code: Continuous Integration for .NET with Travis and xUnit
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CI.Demo
{
public class Feature
{
public string Name { get; private set; }