Skip to content

Instantly share code, notes, and snippets.

@SBoudrias
SBoudrias / readline-test.js
Created May 13, 2013 20:56
Node.js Readline and CLI keypress example
var readline = require('readline'),
_ = require('lodash'),
charm = require('charm')(process.stdout),
rl = readline.createInterface(process.stdin, process.stdout);
var selected = 0;
var choices = [
"foo",
"bar",
"javascript",
@RalfAlbert
RalfAlbert / autoimporter.php
Created April 27, 2013 17:30
WordPress: Class to allow automatically import posts/pages
<?php
/** Display verbose errors */
define( 'IMPORT_DEBUG', false );
// Load Importer API
require_once ABSPATH . 'wp-admin/includes/import.php';
if ( ! class_exists( 'WP_Importer' ) ) {
$class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
if ( file_exists( $class_wp_importer ) )
@19h
19h / reset.js
Created February 19, 2013 22:51
Node.js — Clear Terminal / Console. Reset to initial state.
console.reset = function () {
return process.stdout.write('\033c');
}
@timpulver
timpulver / GetNameAndTitleOfActiveWindow.scpt
Created February 11, 2013 10:38
[AppleScript] Get Name of active window | Returns the name / title of the active (frontmost) window
# taken from user Albert's answer on StackOverflow
# http://stackoverflow.com/questions/5292204/macosx-get-foremost-window-title
# tested on Mac OS X 10.7.5
global frontApp, frontAppName, windowTitle
set windowTitle to ""
tell application "System Events"
set frontApp to first application process whose frontmost is true
set frontAppName to name of frontApp
@jareware
jareware / SCSS.md
Last active May 19, 2024 14:03
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

@jerclarke
jerclarke / Google_OAuth2.php
Last active February 17, 2018 19:40
Google_OAuth2.php from Google Analyticator v.6.4.3 with modifications to fix "Fatal error: Uncaught exception 'Google_AuthException'" See revision history for details on what I changed to fix the error. See this wordpress.org support forum posting about the issue: http://wordpress.org/support/topic/solution-for-fatal-error-uncaught-exception-goo…
<?php
/*
* Copyright 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@kloon
kloon / gist:4545677
Last active May 18, 2020 18:15
WooCommerce limit checkout to quantities in multiples of a number
<?php
// check that cart items quantities totals are in multiples of 6
add_action( 'woocommerce_check_cart_items', 'woocommerce_check_cart_quantities' );
function woocommerce_check_cart_quantities() {
$multiples = 6;
$total_products = 0;
foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
$total_products += $values['quantity'];
}
if ( ( $total_products % $multiples ) > 0 )
@erikreagan
erikreagan / mac-apps.md
Created August 4, 2012 19:18
Mac developer must-haves

Mac web developer apps

This gist's comment stream is a collection of webdev apps for OS X. Feel free to add links to apps you like, just make sure you add some context to what it does — either from the creator's website or your own thoughts.

— Erik

@gerad
gerad / axInfoForProcessIdentifier.m
Created January 20, 2012 04:45
get the name and path of the frontmost window using the carbon mac os accessibility api
// http://stackoverflow.com/questions/2107657/mac-cocoa-getting-a-list-of-windows-using-accessibility-api
// http://stackoverflow.com/questions/853833/how-can-my-app-detect-a-change-to-another-apps-window
// http://cocoatutorial.grapewave.com/tag/axuielementcopyattributevalue/
- (NSDictionary *)axInfoForProcessIdentifier:(NSNumber *)processIdentifier
{
NSMutableDictionary *ret = [NSMutableDictionary dictionaryWithCapacity:2];
pid_t pid = (pid_t) [processIdentifier integerValue];
AXUIElementRef app = AXUIElementCreateApplication(pid);
AXUIElementRef frontWindow = nil;
NSString *title = nil;
@DHS
DHS / PHP Countries Array
Created November 4, 2011 18:51
PHP array of all country names
<?php
$countries = array("Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegowina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia (Hrvatska)", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Island