Skip to content

Instantly share code, notes, and snippets.

var lowerCase = 'abc';
var upperCase = 'ABC';
var symbols = '*!?';
//make strings array
lowerCase = lowerCase.split('');
upperCase = upperCase.split('');
symbols = symbols.split('');
function selectRandom(set){
var Input = pc.createScript('input');
Input.attributes.add('id', { type : 'string' });
Input.attributes.add('autofocus', { type : 'boolean' });
Input.attributes.add('fontSize', { type : 'number' });
Input.attributes.add('padding', { type : 'number' });
Input.attributes.add('margin', { type : 'string' });
Input.attributes.add('type', { type : 'string',
enum: [
{ 'Text Input' : 'text' },
<?php
function applyUpdate($diff, $arr1, $arr2){
$status = false;
if(count($diff['different']) > 0){
foreach ($diff['different'] as $key => $value) {
$exec = '$arr1.'.$value.' = $arr2.'.$value.';';
$exec = preg_replace("/\.(\d{1,3})/", "[$1]", $exec);
$exec = preg_replace('/\.(\w*)/', "['$1']", $exec);
var campaignImage = {
options : {
bgOpacity : 0.7,
fontFamily : 'Arial, sans-serif',
fontSize : 34,
textColor : '#fff'
},
convert : function(element, text){
var canvas = this.imageToCanvas(element);
canvas = this.rectangle(canvas, text);
@devcem
devcem / gist:3f6be212e123c5f181c1
Created January 17, 2016 14:50
Vue sortable component
//Javascript
Vue.component('sort', {
template: "#sort-template",
props : ['data', 'id'],
ready: function (value) {
Sortable.create(document.getElementById(this.id), {
draggable: 'li'
});
}
});
@devcem
devcem / integer-compress.js
Created March 20, 2015 19:06
High ratio number sequence compress
function pad(num,size) {
var s = "000000000" + num;
return s.substr(s.length-size);
}
var bitLength = 2; //Size of each number
var headType = 8; //Min integer in bytes will write in head for index.
function bit(val){
@devcem
devcem / justclick.js
Created March 20, 2015 18:33
Just click
var lastEvent;(function($) {$.fn.justClick = function(callback) {this.bind('mousemove mousedown mouseup', function(e) {if(e.type == 'mouseup' && lastEvent == 'mousedown'){callback()}lastEvent = e.type;});}}(jQuery));
$('#obj').justClick(function(){
console.log("Not move, not drag. It is just click!");
});
//Similar threads
//http://stackoverflow.com/questions/1572483/jquery-mousedown-mousemove
//http://stackoverflow.com/questions/2928161/binding-mousemove-within-mousedown-function-with-jquery
<script>
function similarity(val){
var output = 0;
for(i=0;i<val.length;i++){
output+=val.charCodeAt(0);
}
return parseInt(output/val.length);
@devcem
devcem / gist:955d6cdbe465f550a9e2
Created September 13, 2014 21:23
Javascript sequence
/*
You can use it for animations or sequential processes.
*/
function sequence(){
var length = arguments.length-1;
var delay = arguments[length];
for(i=0;i<length;i++){
setTimeout(
@devcem
devcem / gist:a1a85a9e9473e48a24d0
Created August 5, 2014 09:52
Optimization for Jquery Hide & Show functions
var displayDump = Array();
$.fn.hide = function() {
var selector = this.selector;
displayDump[selector] = Array();
$(this).each(function( index ) {
displayDump[selector].push($(selector)[index].innerHTML);
$(this).css("display","none").html("");
});