Skip to content

Instantly share code, notes, and snippets.

@puiutucutu
puiutucutu / closure_implode.php
Created October 16, 2015 14:46
PHP Closure for merging array values with implode
$names = array_map(function($array) {
return '\'' . $array['Name'] . '\'';
}, $officers_filtered);
@puiutucutu
puiutucutu / push nested array.js
Created October 19, 2015 19:19
push array nested js
responseAsArray = []
// expand to have the correct amount or rows
for(var i = 0; i < 12; i++ ) {
responseAsArray.push([]);
}
// expand all rows to have the correct amount of cols
for (var i = 0; i < response.length; i++) {
responseAsArray[i].push(response[0].Name);
@puiutucutu
puiutucutu / gradient.css
Created October 20, 2015 19:32
gradient css
.btn-primary2:hover {
color: #747d94;
box-shadow: 0 1px rgba(0, 0, 0, 0.05);
border-color: #bdc7d2;
background-color: #f6f7f9; /* fallback color (eg. the gradient center color), if gradients not supported; you could also work with an gradient image, but mind the extra HTTP-Request for older browsers */
-ms-filter: "progid:DXImageTransform.Microsoft.gradient( startColorStr=#f9fafb, EndColorStr=#ddd )"; IE8-9, ColorZilla Ultimate CSS Gradient Generator uses SVG bg image for IE9
background-image: -webkit-linear-gradient( top, #f9fafb, #ddd ); /* Chrome10-25, Saf5.1-Saf6, iOS -6.1, Android -4.3 */
background-image: -moz-linear-gradient( top, #f9fafb, #ddd ); /* Fx3.6-15 */
background-image: -o-linear-gradient( top, #f9fafb, #ddd ); /* Op11.10-12.02 */
background-image: linear-gradient( to bottom, #f9fafb, #ddd ); /* W3C, Fx16+, Chrome26+, IE10+, Op12.10+, Saf6.1+ */
@puiutucutu
puiutucutu / click.js
Created October 22, 2015 19:19
js click
table.addEventListener('click', function(e) {
debug('table was clicked on')
})
table.addEventListener('click')
document.getElementById("testing").onclick = (function(event) {
alert('test')
});
var table = document.getElementById("geocodeTable")
var buttons = document.querySelectorAll('[run-geocode]')
var buttons = document.getElementsByClassName('run')
var buttonsTag = document.getElementsByTagName('button')
for (var i = 0; i < table.rows.length; i++)
{
table.rows[i].onclick = (function (event)
{
var th = rows[0].cells[0].innerHTML
var td = event.target
// var rowid = this.cells[i].innerHTML
// debug(event.currentTargett)
// debug(event.currentTarget)
function debug(obj)
{
console.dir(obj)
}
jQuery(document).ready(function () {
jQuery('body').on('click', '.table', function() {
// alert('touched my table')
});
.circle {
width : 80px;
height : 80px;
border-radius : 40px;
border : solid 10px rgba(255, 255, 255, 0.2);
border-top-color : #FFF;
-webkit-box-sizing: border-box;
-webkit-animation : spin 1s infinite linear;
}
@puiutucutu
puiutucutu / Original.js
Last active October 26, 2015 16:46
jQuery Ajax
/**
* hardcoded and rigid
*/
function ajaxGeocode(data) {
requestAJAX = jQuery.ajax({
method: 'POST',
url: 'php/ajax/geocode.php',
dataType: 'json',
data: { ajax : data }
});
@puiutucutu
puiutucutu / promise.js
Last active October 26, 2015 16:52
JS Promises
function delay() {
// `delay` returns a promise
return new Promise(function(resolve, reject) {
// only `delay` is able to resolve or reject the promise
setTimeout(function() {
resolve(42); // after 3s, resolve the promise with value 42
}, 3000);
});
}