Skip to content

Instantly share code, notes, and snippets.

View alpenzoo's full-sized avatar

Narcis Iulian Paun alpenzoo

View GitHub Profile
@alpenzoo
alpenzoo / fork-example.php
Created April 4, 2018 14:18 — forked from nicksantamaria/fork-example.php
Example: Parallel processing in PHP using pcntl_fork()
<?php
/**
* @file
* Basic demonstration of how to do parallel threads in PHP.
*/
// This array of "tasks" could be anything. For demonstration purposes
// these are just strings, but they could be a callback, class or
// include file (hell, even code-as-a-string to pass to eval()).
<?php
$seed = str_split('abcdefghijklmnopqrstuvwxyz'
.'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
.'0123456789!@#$%^&*()'); // and any other characters
shuffle($seed); // probably optional since array_is randomized; this may be redundant
$rand = '';
foreach (array_rand($seed, 5) as $k) $rand .= $seed[$k];
echo $rand;
@alpenzoo
alpenzoo / scrollable.js
Created April 23, 2018 13:05 — forked from Alex1990/scrollable.js
Stop propagation for scroll/mousewheel
/**
* Stop propagation behavior for scroll of the element but body.
* Compatibility: IE9+
* Ref:
* - http://stackoverflow.com/questions/5802467/prevent-scrolling-of-parent-element#answer-16324762
* - https://developer.mozilla.org/en-US/docs/Web/Events/wheel
*/
;(function ($) {
$.fn.scrollable = function () {
this.on('wheel', function (event) {
@alpenzoo
alpenzoo / no-scroll-to-parent.js
Last active April 23, 2018 13:27
stop mouse scroll on element
$('div').on( 'mousewheel DOMMouseScroll', function (e) {
var e0 = e.originalEvent;
var delta = e0.wheelDelta || -e0.detail;
this.scrollTop += ( delta < 0 ? 1 : -1 ) * 30;
e.preventDefault();
});
@alpenzoo
alpenzoo / index.html
Created June 29, 2018 10:51 — forked from knownasilya/index.html
Google Maps Advanced Drawing
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="UTF-8">
<title>Drawing Tools</title>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false&libraries=drawing"></script>
<style type="text/css">
#map, html, body {
@alpenzoo
alpenzoo / index.html
Created July 5, 2018 07:13 — forked from bjorn-ali-goransson/index.html
Minimal Bootstrap+jQuery+BootstrapJS+FontAwesome template
<!DOCTYPE html>
<html><head>
<meta charset="utf-8">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
</head><body>
<div class="container"><span class="btn btn-success"><i class="fa fa-coffee"></i></span></div>
</body></html>
@alpenzoo
alpenzoo / jquery.hasattr.js
Created July 5, 2018 07:15 — forked from bjorn-ali-goransson/jquery.hasattr.js
jQuery hasAttr function
/* HAS ATTRIBUTE */
$.fn.hasAttr = function(attrName){
var element = this[0];
if(element.hasAttribute){
return element.hasAttribute(attrName);
@alpenzoo
alpenzoo / GoogleMapDivider.php
Created July 16, 2018 14:33 — forked from jamestomasino/GoogleMapDivider.php
PHP file to divide up a large image into Google Map tiles
<?php
//Larger images can require more memory and time
ini_set('memory_limit','2048M');
ini_set('max_execution_time','300');
//For testing purposes, I manually entered the input file name and destination folder
$destinationDir = 'tiles/';
$fileName = 'map.jpg';
if (!file_exists($destinationDir)) {
@alpenzoo
alpenzoo / traverse.js
Created September 14, 2018 08:10 — forked from tushar-borole/traverse.js
Object tree traversal in javascript (with lodash)
var data = {
"name": "root",
"contents": [
{
"name": "A",
"contents": [
{
"name": "fileA1",
"contents": []
}
@alpenzoo
alpenzoo / index.html
Created September 21, 2018 12:08 — forked from romaricdrigon/index.html
Minimal HTML boilerplate
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Title</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
</head>
<body>