Skip to content

Instantly share code, notes, and snippets.

@sTiLL-iLL
sTiLL-iLL / dobVal.js
Last active December 21, 2015 23:39
validate D.O.B.
// Validate date of birth
$("#frm1").submit(function(){
var d = $("#day").val();
var mth = $("#month").val();
var yr = $("#year").val();
// arbitrary number for example
var age = 18;
@sTiLL-iLL
sTiLL-iLL / ajaxPreloader.js
Created August 24, 2013 18:53
ajaxn - ified image preloader... its gewd!
(function() {
var f = [];
$.ajax({
url: "imgz.js",
type: "GET",
contentType: "json",
cache: true,
success: function(data) {
var j = JSON.parse(data);
var $c = $("#container");
/*
* Options:
* - before (string): HTML code before the tweet.
* - after (string): HTML code after the tweet.
* - tweets (numeric): number of tweets to display.
*
* Example:
*
* <script type="text/javascript" charset="utf-8">
* $(document).ready(function() {
@sTiLL-iLL
sTiLL-iLL / custom video embed.js
Last active December 21, 2015 10:28
Generate a embed widget on the fly!
//store the URL
var url = "http://vimeo.com/71673549";
//extract the ID
var rgx = /\/\/(www\.)?vimeo.com\/(\d+)($|\/)/;
//the ID: 71673549
var id = url.match(rgx);
var width = '640';
@sTiLL-iLL
sTiLL-iLL / check if cookies are turned on
Last active December 21, 2015 08:38
more helpful JS functions for your pleasure!
// Check if cookies are enabled
$(document).ready(function() {
var dt = new Date();
dt.setSeconds(dt.getSeconds() + 60);
document.cookie = "cookietest=1; expires=" + dt.toGMTString();
var cookiesEnabled = document.cookie.indexOf("cookietest=") != -1;
if(!cookiesEnabled){
//cookies are not enabled
}
@sTiLL-iLL
sTiLL-iLL / functional js type shit
Created August 20, 2013 09:02
helpful snips O' javascript!
// How to get client ip address with jQuery
$.getJSON("http://jsonip.appspot.com?callback=?",function(data){
alert( "Your ip: " + data.ip);
});
// How to parse XML with jQuery
// file.xml:
@sTiLL-iLL
sTiLL-iLL / sniffColors
Created August 20, 2013 08:30
Compare the color values of individual pixels by calculating the vector positioning between individual pixels within the standard ternary groupings "(R,G,B)".. Use this to detect nudity, etc...
public static unsafe void sniffColors(Bitmap bmp,
byte r, byte g, int b, int heft)
{
BitmapData dta = image.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height),
ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
int bPxl=3;
byte* chk1=(byte*)imageData.Scan0.ToPointer();
int trn=imageData.Stride;
int hgt=imageData.Height;
int wdt=imageData.Width;
@sTiLL-iLL
sTiLL-iLL / datalist examples
Last active December 21, 2015 02:29
datalist experiments....
// month type options
<input type="month" list="months" />
<datalist id="months">
<option label="Eiji's birthday">1976-02</option>
<option label="End of last century">2000-12</option>
<option>2010-01</option>
<option label="Now">2012-11</option>
</datalist>
// week options
@sTiLL-iLL
sTiLL-iLL / funCyLib.js
Last active December 20, 2015 15:08
more abstractions...
function map(func, array) {
var len = array.length;
var rst = new Array(len);
for (var i = 0; i < len; i++)
rst[i] = func(array[i]);
return rst;
}
function reduce(func, start, array) {
var len = array.length;
@sTiLL-iLL
sTiLL-iLL / 4EveryOne.js
Created August 4, 2013 18:48
4 all Items in a list loop logic
// on every "yada" in "yada"....
function onEachIn(object, action) {
try {
for (var property in object) {
if (Object.prototype.hasOwnProperty.call(object, property))
action(property, object[property]);
}
} catch (e) {
throw e;