Skip to content

Instantly share code, notes, and snippets.

View ceaksan's full-sized avatar
🤹

Ceyhun Aksan ceaksan

🤹
View GitHub Profile
function repeat(str, num) {
var result;
num > 0 ? result = str.repeat(num) : result = '';
return result;
}
repeat("abc", 3, "");
function repeat(str, num) {
if(num === 0) { return str; }
else if(num > 0) {
var newStr = '';
var i = 0;
while(num > i){ newStr += str; i++; }
return newStr;
} else { return ''; }
}
repeat("abc", 3, "");
function truncate(str, num) {
if(str.length > num) str = str.slice(0, num - 3) + '...';
return str;
}
truncate('A-tisket a-tasket A green and yellow basket', 11);
function chunk(arr, size) {
var temp = [], i = 0;
while (i < arr.length) {
temp.push(arr.slice(i, i += size));
}
return temp;
}
function chunk(arr, size) {
var temp = [], result = [];
for (var a = 0; a < arr.length; a++) {
if (a % size !== size - 1) temp.push(arr[a]);
else { temp.push(arr[a]); result.push(temp); temp = []; }
}
if (temp.length !== 0) result.push(temp);
return result;
}
function factorialize(num) {
var deger = 1;
for(num; num > 1; num--) deger *= num;
return deger;
}
factorialize(5, '');
function cea_wpAddMenuDrafts() {
add_posts_page(__('Drafts'), __('Drafts'), 'read', 'edit.php?post_status=draft&post_type=post');
}
add_action('admin_menu', 'cea_wpAddMenuDrafts');
import processing.video.*;
import com.google.zxing.*;
import java.awt.image.BufferedImage;
Capture cam; //Set up the camera
com.google.zxing.Reader reader = new com.google.zxing.qrcode.QRCodeReader();
int WIDTH = 640;
int HEIGHT = 480;
jQuery(document).ready(function() {
jQuery(':input').blur(function () {
var formName = {{FORM NAME}}; // Change {{FORM NAME}}
if(jQuery(this).val().length > 0) {
_gaq.push(['_trackEvent', formName, 'Completed', jQuery(this).attr('name')]);
}
else {
_gaq.push(['_trackEvent', formName, 'Canceled', jQuery(this).attr('name')]);
}
});