Skip to content

Instantly share code, notes, and snippets.

View andreasvirkus's full-sized avatar
🙊
made you look

andreas andreasvirkus

🙊
made you look
View GitHub Profile
@keenahn
keenahn / file-upload-validation.js.coffee
Created December 3, 2012 21:29
JS: File upload validation
# 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 April 14, 2014 10:28
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
input[type="password"]
{
font: large Verdana,sans-serif;
letter-spacing: 1px;
}
@lambtron
lambtron / sorter.js
Created October 20, 2015 17:27
Custom sort method for metalsmith-collections plugin in Segment's technical documentation.
/**
* 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 January 22, 2015 03:30
Ajax request with Vanilla 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 October 15, 2012 11:26 — forked from db/jquery.ajax.progress.js
add XHR2 upload and download progress events to jQuery.ajax
(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 April 12, 2012 18:15
Running Windows under Ubuntu to test in Internet Explorer

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 20:30
hidden-toggle for cmb. Works like the WordPress metabox toggle (but for only a selection of fields)
.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 {
@mzalewski
mzalewski / node-wpapi-oauth-option1.js
Created October 24, 2016 23:10
Node WPAPI OAuth examples
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 February 23, 2019 21:40
WordPress On Vagrant
# -*- 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"
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}' ` }