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
@startupcode
startupcode / HtmlToAttributedString.swift
Last active October 3, 2023 01:08
Swift - Assign HTML to NSAttributedString with custom FONT
//Usage
lbl.attributedText = htmlToAttributedString ("html text")
//Assign attributed string
func htmlToAttributedString(string : String) -> NSAttributedString{
var attribStr = NSMutableAttributedString()
do {//, allowLossyConversion: true
attribStr = try NSMutableAttributedString(data: string.dataUsingEncoding(NSUnicodeStringEncoding)!, options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil)
@cesarfigueroa
cesarfigueroa / paste.js
Created September 25, 2014 23:48
Paste onto a [contenteditable] element as plain text
document.querySelector('[contenteditable]').addEventListener('paste', function (event) {
event.preventDefault();
document.execCommand('inserttext', false, event.clipboardData.getData('text/plain'));
});
@arielsalminen
arielsalminen / iOS8-scroll-event-test.html
Created August 25, 2014 14:13
iOS 8 Safari doesn’t disable scroll events anymore (A test page).
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>iOS 8 scrolls</title>
<meta name="viewport" content="width=device-width">
</head>
<body style="min-height: 20000px;">
<div class="scroller" style="text-align: center; line-height: 4em; position: fixed; top: 0; left: 0; right: 0; height: 4em; background: red; color: #fff; font-family: sans-serif;">We’re here.</div>
<script>
@olasd
olasd / stream_to_youtube.sh
Created March 28, 2014 19:58
Stream video to youtube via ffmpeg
#! /bin/bash
#
# Diffusion youtube avec ffmpeg
# Configurer youtube avec une résolution 720p. La vidéo n'est pas scalée.
VBR="2500k" # Bitrate de la vidéo en sortie
FPS="30" # FPS de la vidéo en sortie
QUAL="medium" # Preset de qualité FFMPEG
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" # URL de base RTMP youtube
@wizard04wsu
wizard04wsu / notifications.js
Created February 12, 2014 19:49
Cross-browser desktop notifications (for supporting browsers)
//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])
@DevinWalker
DevinWalker / woocommerce-optimize-scripts.php
Last active January 8, 2024 13:24
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* 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' ) );
@dyaa
dyaa / check.js
Created September 30, 2013 15:02
Check if jplayer is playing
$("#jquery_jplayer_1").jPlayer({
swfPath: "http://www.jplayer.org/latest/js/Jplayer.swf",
ready: function () {
$(this).jPlayer("setMedia", { mp3: "http://77.68.106.224:8018/;stream/1" });
},
supplied: "mp3"
});
setInterval(function () {
var isPaused = $('#jquery_jplayer_1').data().jPlayer.status.paused;
@JohanObrink
JohanObrink / gist:5796334
Last active December 18, 2015 14:19
Fix for Array.prototype.slice.call not working on NodeLists in IE8
(function() {
if(navigator.appVersion.indexOf('MSIE 8') > 0) {
var _slice = Array.prototype.slice;
Array.prototype.slice = function() {
if(this instanceof Array) {
return _slice.apply(this, arguments);
} else {
var result = [];
var start = (arguments.length >= 1) ? arguments[0] : 0;
var end = (arguments.length >= 2) ? arguments[1] : this.length;
@vitalyrotari
vitalyrotari / gestures.js
Last active April 21, 2023 16:35
Vanilla JS Touch Gestures | Original Size: 6.71KB (2.08KB gzipped) | Compiled Size: 2.69KB (1.2KB gzipped)
/*
* Vanilla JS - Touch Gestures
* @version 0.1
* @inspired QuoJS - http://quojs.tapquo.com
*
* Supported Gestures: singleTap, doubleTap, hold,
* swipe, swiping, swipeLeft, swipeRight, swipeUp, swipeDown,
* rotate, rotating, rotateLeft, rotateRight, pinch, pinching,
* pinchIn, pinchOut,
* drag, dragLeft, dragRight, dragUp, dragDown
/**
* Retrieve posts ids given their title.
* Use this function if there are more than one post with the same title.
*/
function get_multiple_posts_by_title($title) {
global $wpdb;
$posts_ids = array();
$posts = $wpdb->get_results( $wpdb->prepare( “SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type=’post_type’”, $title), OBJECT );
foreach ($posts as $post) {