Skip to content

Instantly share code, notes, and snippets.

@Ariex
Ariex / gist:5a8a54ea8bb9ded073a4
Last active August 29, 2015 14:21
Animate.css color animation
<!-- example: https://jsfiddle.net/Ariex/ouoq0jbw/ -->
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Roboto:400,100,400italic,700italic,700&type=.css">
<style>
@keyframes hue {
from {
filter: hue-rotate(0deg);
-webkit-filter: hue-rotate(0deg);
}
to {
filter: hue-rotate(-360deg);
using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
namespace Routing.Modules
{
public class WebAPIBridgeModule : IHttpModule
/* WebKit */
-webkit-filter: invert();
/* Firefox */
filter: url("data:image/svg+xml;utf8,<svg height='0' xmlns='http://www.w3.org/2000/svg'><filter id='negative'><feColorMatrix values='-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0'/></filter></svg>#negative");
/* IE 6-7 */
filter: progid:DXImageTransform.Microsoft.BasicImage(invert=1);
/* IE 8 */
-ms-filter: 'progid:DXImageTransform.Microsoft.BasicImage(invert=1)';

my code as below

$fields->insertBefore($isTrueField = CheckboxField::create('IsTrue', 'Is it true?'), 'OtherField');
$fields->dataFieldByName('AnotherField')->setAttribute('data-attribute', $isTrueField->ID());

the outputs is checkbox

@Ariex
Ariex / useful-regex.md
Last active August 29, 2015 14:26
Useful Regex

matches vimeo video Id

^https?:\/\/(?:www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|)(\d+)(?:$|\/|\?)$

matches youtube video Id

(from http://stackoverflow.com/a/26445466/903505)

@Ariex
Ariex / gist:977eaf219bd29de45a25
Last active August 29, 2015 14:27 — forked from evantahler/gist:1574158
Build Node on Phidget (ARMv4tl + emdebian)
@Ariex
Ariex / StringLocker.cs
Last active June 9, 2016 23:37
An implementation for helping to solve concurrent issue when multiple client write to multiple file
using System;
using System.Collections.Generic;
/// <summary>
/// Create a lock block against a string
/// </summary>
public class StringLocker
{
/// <summary>
/// Store map from string to lockable object
@Ariex
Ariex / git-move-files-in-subfolder.md
Created April 13, 2016 05:13 — forked from ajaegers/git-move-files-in-subfolder.md
Git: move files in an subfolder keeping history

Change structure of project folder with Git

I have this structure:

 project-folder/
     .git
     wp-admin/
     wp-content/
     wp-includes/

.htaccess

/// <summary>
/// Evaluates the arguments in order and returns the current value of the first expression that initially does not evaluate to NULL.
/// </summary>
/// <typeparam name="T">Target Type, has to be a class type</typeparam>
/// <param name="validator">An evaluation method, check if current alternative is valid as a return value.</param>
/// <param name="that">The first alternative value</param>
/// <param name="alternatives">Alternatives could be a value that is or can convert to target type; or a Func that return value as target type.</param>
/// <returns>The first value that is not null (or white spaces for string) in arguments.</returns>
public static T Coalesce<T>(this T that, Func<T, bool> validator, params object[] alternatives) where T : class
{
@Ariex
Ariex / GetBase64GifSpacer.cs
Created June 26, 2016 12:59
Create a transparent gif spacer with specified width and height
public static string GetBase64GifSpacer(int width, int height){
var bwidth = BitConverter.GetBytes(width);
var bheight = BitConverter.GetBytes(height);
var bytes = new byte[] { 0x47,0x49,0x46,0x38,0x39,0x61,bwidth[0],bwidth[1],bheight[0],bheight[1],0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0xF9,0x04,0x01,0x00,0x00,0x00,0x00,0x2C,0x00,0x00,0x00,0x00,bwidth[0],bwidth[1],bheight[0],bheight[1],0x00,0x02,0x02,0x44,0x01,0x00,0x3B };
return "data:image/gif;base64,"+Convert.ToBase64String(bytes);
}