Skip to content

Instantly share code, notes, and snippets.

Avatar
🙊
made you look

andreas andreasvirkus

🙊
made you look
View GitHub Profile
View file-upload-validation.js.coffee
# Just some examples of how to do file validation with javascript
# IS NOT BULLETPROOF and should be coupled with server side validation
# But, it can help
validate_file = ->
file = @fileInput.files[0]
if "name" of file
name = file.name
else
name = file.fileName
if "size" of file
@siggiarni
siggiarni / Password-Fields.css
Created Apr 14, 2014
The only font that emulate correctly the password field's big dots of other browsers is Verdana.See: http://stackoverflow.com/questions/6859727/styling-password-fields-in-css
View Password-Fields.css
input[type="password"]
{
font: large Verdana,sans-serif;
letter-spacing: 1px;
}
@lambtron
lambtron / sorter.js
Created Oct 20, 2015
Custom sort method for metalsmith-collections plugin in Segment's technical documentation.
View sorter.js
/**
* Generate a custom sort method for given starting `order`. After the given
* order, it will ignore casing and put periods last. So for example a call of:
*
* sorter('Overview');
*
* That is passed:
*
* - Analytics.js
@ianaya89
ianaya89 / ajax.js
Created Jan 22, 2015
Ajax request with Vanilla JS
View ajax.js
function ajax(type, url) {
var request = new XMLHttpRequest();
request.open(type, url, true);
request.onload = function() {
if (this.status >= 200 && this.status < 400) {
//succes.
var resp = this.response;
}
else {
@nebirhos
nebirhos / jquery.ajax.progress.js
Created Oct 15, 2012 — forked from db/jquery.ajax.progress.js
add XHR2 upload and download progress events to jQuery.ajax
View jquery.ajax.progress.js
(function addXhrProgressEvent($) {
var originalXhr = $.ajaxSettings.xhr;
$.ajaxSetup({
xhr: function() {
var req = originalXhr(), that = this;
if (req) {
if (typeof req.addEventListener == "function" && that.progress !== undefined) {
req.addEventListener("progress", function(evt) {
that.progress(evt);
}, false);
@fedemp
fedemp / index.markdown
Created Apr 12, 2012
Running Windows under Ubuntu to test in Internet Explorer
View index.markdown

How to test Internet Explorer 6 to 9 in Ubuntu

The final purpose of this tutorial is to have a Windows (XP, Vista, 7) running a native installation of Internet Explorer (6, 7, 8, 9). Windows will work as a guest in on Virtualbox running on Ubuntu. We will also make sure to have access to virtual hosts configured in the host OS.

Following steps have to be run on Ubuntu (or whatever flavor of Linux you have)

Download disk images of Windows

First step is to download Windows Virtual PC VHDs for testing websites with different Internet Explorer versions . These disk images are installations of different Windows versions with Internet Explorer installed. It's perfectly legal to use to any of these images; free as in beer.

Once you have download them, you will find that they are RAR files and one of them is an .exe file. Just rename the .exe file to .rar and we can continue.

@jtsternberg
jtsternberg / cmb-toggle-fields.css
Last active May 11, 2017
hidden-toggle for cmb. Works like the WordPress metabox toggle (but for only a selection of fields)
View cmb-toggle-fields.css
.advanced-toggle .toggle-label {
cursor: pointer;
display: block;
line-height: 3em;
border-bottom: 1px solid #e9e9e9;
border-left: 1px solid #e9e9e9;
border-right: 1px solid #e9e9e9;
padding-left: .8em;
}
.advanced-toggle .inside .cmb-row {
View node-wpapi-oauth-option1.js
var WPAPI = require( 'wpapi' );
var wp = new WPAPI({
endpoint: endpointUrl,
oauth: {
clientId: clientId,
clientSecret: clientSecret,
callback: callbackUrl // optional: (defaults to oob)
}
});
@danielpataki
danielpataki / Vagrantfile
Last active Feb 23, 2019
WordPress On Vagrant
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :private_network, ip: "192.168.99.99"
View longpress-directive.js
Vue.directive('longpress', {
bind: function (el, binding, vNode) {
// Make sure expression provided is a function
if (typeof binding.value !== 'function') {
// Fetch name of component
const compName = vNode.context.name
// pass warning to console
let warn = `[longpress:] provided expression '${binding.expression}' is not a function, but has to be`
if (compName) { warn += `Found in component '${compName}' ` }