Skip to content

Instantly share code, notes, and snippets.

View kaskajp's full-sized avatar
🙈
ASCII stupid question, get a stupid ANSI!

Jonas Raneryd Imaizumi kaskajp

🙈
ASCII stupid question, get a stupid ANSI!
View GitHub Profile
@kaskajp
kaskajp / 0_reuse_code.js
Created May 26, 2014 09:55
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<?php /* This function attaches the image to the post in the database, add it to functions.php */
function insert_attachment($file_handler,$post_id,$setthumb='false') {
// check to make sure its a successful upload
if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
<?php
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
@kaskajp
kaskajp / wp-cpt-loop.php
Created March 17, 2015 12:17
Custom Post Type Loop
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts(array(
'post_type' => 'myposttype',
'posts_per_page' => 10,
'paged' => $paged)
);
?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
@kaskajp
kaskajp / my-cpt.php
Created March 17, 2015 12:18
Custom Post Type as Plugin
<?php
/*
Plugin Name: A Custom Post Type
Plugin URI: http://kaska.jp/
Description: A simple barebones custom post type.
Version: 1.0
Author: Jonas Raneryd
Author URI: http://kaska.jp/
License: MIT
*/
@kaskajp
kaskajp / animate-pathstring.js
Last active August 29, 2015 14:17
Animate Path String with RaphaelJS
var animatePathString = function(canvas, colorNumber, pathString) {
var line = canvas.path(pathString).attr({
stroke: colorNumber
});
var length = line.getTotalLength();
$('path[fill*="none"]').animate({
'to': 1
}, {
@kaskajp
kaskajp / sequence-addclass.js
Last active August 29, 2015 14:17
Sequence Add Class
var sequenceAddClass = function(els) {
function addClassWithTimeout(i, el) {
var t = setTimeout(function() {
clearTimeout(t);
el.className = el.className + "addsomeclass";
}, i * 200);
}
for (var i = 0; i < els.length; i++) {
addClassWithTimeout(i, els[i]);
}
@kaskajp
kaskajp / example.html
Created March 17, 2015 12:23
Responsive Flexbox Example
<div class="container">
<div class="image">
<img src="http://placetokyo.com/100/100" alt="" />
</div>
<div class="name-location">
<div class="name">This be the name</div>
<div class="location">This be the location</div>
</div>
<div class="buttons">
<a href="#">Button</a>
@kaskajp
kaskajp / grid.scss
Created March 23, 2015 14:15
SCSS Grid
$gridgutter: 30;
$gridpadding: 30;
$gridsize: 978 + ($gridpadding*2);
$gridcolsize: (($gridsize - ($gridgutter * 11)) / 12);
.grid {
width: 100%;
max-width: $gridsize+px;
margin: 0 auto;
padding-left: $gridpadding+px;
padding-right: $gridpadding+px;
//http://www.w3.org/TR/notifications/
//https://developer.mozilla.org/en-US/docs/Web/API/notification
//Notifier.isSupported
//
//Notifier.permission //"granted", "denied", or "default"
//
//Notifier.requestPermission([callback]) //first argument of callback is the current permission
//
//Notifier.notify(title[, options])