Skip to content

Instantly share code, notes, and snippets.

@sp1r1don
sp1r1don / android.txt
Created July 2, 2020 13:06 — forked from srishanbhattarai/android.txt
Android Emulator CPU/Memory high usage solution
https://stackoverflow.com/questions/37063267/high-cpu-usage-with-android-emulator-qemu-system-i386-exe
The cause of the constant CPU usage is the sound. If you do not need sound in your emulator you can disable it by editing the AVD's config file.
Change/add those two lines
hw.audioInput=no
hw.audioOutput=no
On Linux/Mac the file is located at ~/.android/avd/<AVD_Name>.avd/config.ini
On Windows the file is located at C:\Users\<username>\.android\avd\<AVD_Name>.avd\config.ini
@sp1r1don
sp1r1don / pyshop task 1
Created July 11, 2018 13:18
pyshop tasks
var matrixExample = [
[ 1, 2, 3, 4 ],
[ 4, 5, 6, 5 ],
[ 7, 8, 9, 7 ],
[ 7, 8, 9, 7 ]
];
function sumUpDiagonals(matrix) {
var sumMain = 0;
var sumSec = 0;
@sp1r1don
sp1r1don / gist:1ff6ede0dc049fb1c11b467e7fd4b5f6
Created July 10, 2018 14:08
IIS web.config CORS disable Authorization when request method 'OPTIONS'.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<authorization>
<remove users="*" roles="" verbs="" />
<add accessType="Allow" users="?" verbs="OPTIONS" />
</authorization>
</security>
<httpProtocol>
@sp1r1don
sp1r1don / swipe
Created November 16, 2017 11:10
Simple swipe
let xDown = null;
let yDown = null;
function handleTouchStart(evt) {
xDown = evt.touches[0].clientX;
yDown = evt.touches[0].clientY;
}
function handleTouchMove(evt) {
if ( ! xDown || ! yDown ) {
@sp1r1don
sp1r1don / fluid.styl
Last active November 14, 2017 11:18
Fluid font stylus mixin
//Fluid font
//fluid-type(320px, 2560px, 16px, 20px) for 2.5k resolution
fluid-type(min-vw, max-vw, min-font-size, max-font-size)
u1 = unit(min-vw)
u2 = unit(max-vw)
u3 = unit(min-font-size)
u4 = unit(max-font-size)
if u1 == u2 and u1 == u3 and u1 == u4
&
font-size: min-font-size
@sp1r1don
sp1r1don / html5-dataset.js
Created November 11, 2017 15:59 — forked from brettz9/html5-dataset.js
Dataset Shim
/**
* Add dataset support to elements
* No globals, no overriding prototype with non-standard methods,
* handles CamelCase properly, attempts to use standard
* Object.defineProperty() (and Function bind()) methods,
* falls back to native implementation when existing
* Inspired by http://code.eligrey.com/html5/dataset/
* (via https://github.com/adalgiso/html5-dataset/blob/master/html5-dataset.js )
* Depends on Function.bind and Object.defineProperty/Object.getOwnPropertyDescriptor (polyfills below)
* All code below is Licensed under the X11/MIT License
@sp1r1don
sp1r1don / disableScroll.js
Created October 13, 2017 11:30
js scroll disable
//*****************************//
//***Scroll disable***//
//*****************************//
// left: 37, up: 38, right: 39, down: 40,
// spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36
let keys = {37: 1, 38: 1, 39: 1, 40: 1};
function preventDefault(e) {
e = e || window.event;
@sp1r1don
sp1r1don / fonts.styl
Created September 14, 2017 11:47 — forked from diogomoretti/fonts.styl
Stylus mixin @font-face
// Fonts mixin
font-url(file)
return '../fonts/' + file
webfont(family, file, hack-chrome-windows = false, weight = 'normal')
@font-face
font-family family
src url(font-url(file + '.eot'))
src url(font-url(file + '.eot?#iefix')) format('embedded-opentype'),
url(font-url(file + '.woff')) format('woff'),
@sp1r1don
sp1r1don / image-load.js
Last active September 12, 2017 14:04
AJAX image load for masonry.desandro
$.fn.imagesLoaded = function () {
// get all the images
let $imgs = this.find('img[src!=""]');
// if there's no images return resolved promise
if (!$imgs.length) {return $.Deferred().resolve().promise();}
// for each image, add a deferred object to the array
let dfdarr = [];
$imgs.each(function(){