Skip to content

Instantly share code, notes, and snippets.

View lucien144's full-sized avatar
🤘
Refactor!

lucien144

🤘
Refactor!
View GitHub Profile
/**
* NetteForms - simple form validation.
*
* This file is part of the Nette Framework.
* Copyright (c) 2004, 2014 David Grudl (http://davidgrudl.com)
*/
var Nette = Nette || {};
Nette.errors = [];
@lucien144
lucien144 / LESS breakpoints
Created April 28, 2014 13:49
Less variables to be used with media queries
// Breakpoints
// ------------------------- Source: http://blog.scur.pl/2012/06/variable-media-queries-less-css/
@highdensity: ~"only screen and (-webkit-min-device-pixel-ratio: 1.5)",
~"only screen and (min--moz-device-pixel-ratio: 1.5)",
~"only screen and (-o-min-device-pixel-ratio: 3/2)",
~"only screen and (min-device-pixel-ratio: 1.5)";
@mobile: ~"only screen and (max-width: 529px)";
@tablet: ~"only screen and (min-width: 530px) and (max-width: 949px)";
@desktop: ~"only screen and (min-width: 950px) and (max-width: 1128px)";
@desktop-xl: ~"only screen and (min-width: 1129px)";
<?php
function isEmail($value)
{
$atom = "[-a-z0-9!#$%&'*+/=?^_`{|}~]"; // RFC 5322 unquoted characters in local-part
$localPart = "(?:\"(?:[ !\\x23-\\x5B\\x5D-\\x7E]*|\\\\[ -~])+\"|$atom+(?:\\.$atom+)*)"; // quoted or unquoted
$alpha = "a-z\x80-\xFF"; // superset of IDN
$domain = "[0-9$alpha](?:[-0-9$alpha]{0,61}[0-9$alpha])?"; // RFC 1034 one domain component
$topDomain = "[$alpha](?:[-0-9$alpha]{0,17}[$alpha])?";
return (bool) preg_match("(^$localPart@(?:$domain\\.)+$topDomain\\z)i", $value);
}
@lucien144
lucien144 / auto-slide.coffee
Last active October 10, 2015 19:27
Slide to HTML element
$('html, body').animate
scrollTop: $("#element").offset().top
, 2000
@lucien144
lucien144 / scrolling.coffee
Created October 31, 2014 21:34
Disable / Enable scroll
# Original post: http://stackoverflow.com/questions/4770025/how-to-disable-scrolling-temporarily
class @Scrolling
@keys
constructor: ->
Scrolling::keys = [37, 38, 39, 40]
preventDefault: (e) ->
e = e || window.event;
@lucien144
lucien144 / gist:a6ef87c21e8b28128af8
Created January 12, 2015 09:34
App's descriptor for testing Air apps with Testflight (iOS8)
<iPhone>
<Entitlements>
<![CDATA[
<key>get-task-allow</key>
<false/>
<key>beta-reports-active</key>
<true/>
]]>
</Entitlements>
...
@lucien144
lucien144 / svg-spinner.ajax.coffee
Last active August 29, 2015 14:16
ajax.nette.js - SVG spinner
$.nette.ext 'svg-spinner',
start: (c, s) ->
if s.nette.el
for i in s.nette.el
$(i).closest('*[id^=snippet--]').addClass 'svgSpinner'
# source: http://codepen.io/aurer/pen/jEGbA?editors=110
$(i).closest('*[id^=snippet--]').append '<div class="snippet-wrapper"><div class="loader"> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"width="24px" height="30px" viewBox="0 0 24 30" style="enable-background:new 0 0 50 50;" xml:space="preserve"> <rect x="0" y="13" width="4" height="5" fill="#333"> <animate attributeName="height" attributeType="XML"values="5;21;5"begin="0s" dur="0.6s" repeatCount="indefinite" /> <animate attributeName="y" attributeType="XML"values="13; 5; 13"begin="0s" dur="0.6s" repeatCount="indefinite" /> </rect> <rect x="10" y="13" width="4" height="5" fill="#333"> <animate attributeName="height" attributeType="XML"values="5;21;5"begin="0.15s" dur="0.6s" repeatCount="indefinite" /> <animate attributeName="y"
@lucien144
lucien144 / build.php
Last active September 18, 2015 14:26
Packaging Adobe Air app for iOS
<?php
$appName = 'FILENAME';
$adt = '/Applications/AIRSDK_Compiler/18/bin/adt';
$target = 'ipa-app-store';
$connect = '';
$descriptor = 'application-testflight.xml';
$cert = './cert/iOS/CERT.p12';
$content = 'bin';
$lib = './lib';
@lucien144
lucien144 / gist:6a44601d477784669aab
Created July 17, 2015 13:05
Autodeploy from Bitbucket using new webhooks and Pushbullet notifications
<?php
# Install
# sudo chown -R :apache ./*
# sudo chmod 0775 -R ./*
# sudo -u apache git pull # Optional
# sed -i 's/filemode\ =\ true/filemode\ =\ false/g' .git/config
if (!isset($_GET['token']) || $_GET['token'] != md5('*****')) {
exit('Wrong token. Terminating.');
}
<?php
/*
This is an update of https://wordpress.org/plugins/tumblr-importer/ that fixes several issues:
- do not skip posts without title/content
- when importing 1 image import it as a WP type image instead of gallery
- when importing images, import first image as a post's featured image
Plugin Name: Tumblr Importer
Plugin URI: http://wordpress.org/extend/plugins/tumblr-importer/