Skip to content

Instantly share code, notes, and snippets.

View jcubic's full-sized avatar
🎯
Focusing

Jakub T. Jankiewicz jcubic

🎯
Focusing
View GitHub Profile
@jcubic
jcubic / ReflectService.java
Last active August 9, 2017 20:55
ReflectService plugin
package com.example.package;
import android.content.Context;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.io.PrintWriter;
@jcubic
jcubic / display.sh
Last active December 27, 2016 10:53
Toggle Display and keyboard highlight on asus laptop on GNU/Linux
#!/bin/bash
file=/tmp/display
KBBL="/sys/class/leds/asus::kbd_backlight"
if [ -e $file ]; then
rm $file
sudo vbetool dpms on
[ -d $KBBL -o -f $KBBL ] && echo 3 | sudo tee $KBBL/brightness > /dev/null
@jcubic
jcubic / cssFragID.js
Created December 23, 2016 13:07
Implementation of "Using CSS Selectors as Fragment Identifiers" Unofficial Draft
function jump() {
var match = location.hash.match(/^#css\((.*)\)$/);
if (match) {
window.scrollTo(0, document.querySelector(match[1]).offsetTop);
}
}
jump();
window.addEventListener("hashchange", jump, false);
@jcubic
jcubic / dabblet.css
Created November 22, 2016 14:31
Untitled
.toggle-switch {
display: inline-block;
position: relative;
border-radius: 20px;
background-color: #E6E6E6;
padding: 10px;
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select: none;
}
@jcubic
jcubic / jquery.terminal-src.js
Created September 2, 2016 16:12
Development version of jQuery Terminal without content editable
/**@license
* __ _____ ________ __
* / // _ /__ __ _____ ___ __ _/__ ___/__ ___ ______ __ __ __ ___ / /
* __ / // // // // // _ // _// // / / // _ // _// // // \/ // _ \/ /
* / / // // // // // ___// / / // / / // ___// / / / / // // /\ // // / /__
* \___//____ \\___//____//_/ _\_ / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/
* \/ /____/ version {{VER}}
*
* This file is part of jQuery Terminal. http://terminal.jcubic.pl
*
@jcubic
jcubic / cross-domain.js
Last active December 10, 2018 20:34
Cross domain ajax request without CORS using iframe and postMessage
$.fn.crossDomainRequest = function(url, method, data, fn) {
var self = this;
var receiver = self.attr('src').replace(/\/.*$/, '').replace(/^https?::\/\//, '');
function get(event) {
if (event.origin.match(receiver)) {
// event.data is response from POST
fn(event.data);
}
}
if (window.addEventListener){
@jcubic
jcubic / escape.js
Created May 18, 2016 15:07
Escape String as per EcmaScript spec
/*
* implementation of the alorithm from EcmaScript spec in section 15.1.2.4
* http://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf
*/
(function(global) {
var allowed = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_+-./,';
global.escapeString = function(str) {
str = str.toString();
var len = str.length, R = '', k = 0, S, chr, ord;
while(k < len) {
@jcubic
jcubic / findText.js
Last active February 19, 2016 22:35
findText function
function findText( rootElement, textToFind ) {
var walker = document.createTreeWalker( rootElement,
NodeFilter.SHOW_TEXT,
null,
false );
var texts = [],
nodes = [];
walker.firstChild();
nodes.push( walker.currentNode );
@jcubic
jcubic / browser.js
Last active August 29, 2015 14:05
MVVM demo with route.js, jsViews, jQuery and hashchange
(function() {
var matched, browser;
// Use of jQuery.browser is frowned upon.
// More details: http://api.jquery.com/jQuery.browser
// jQuery.uaMatch maintained for back-compat
jQuery.uaMatch = function( ua ) {
ua = ua.toLowerCase();
@jcubic
jcubic / keybase.md
Created August 15, 2014 07:56
Kebase.io proof

Keybase proof

I hereby claim:

  • I am jcubic on github.
  • I am jcubic (https://keybase.io/jcubic) on keybase.
  • I have a public key whose fingerprint is BC65 3F92 314B 398B 5E1E 0BC7 A58E E6F1 31F8 3013

To claim this, I am signing this object: