Skip to content

Instantly share code, notes, and snippets.

@yuristrelets
yuristrelets / index.html
Created September 11, 2018 15:27
Electron Fiddle Gist
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body>
<canvas></canvas>
<script>
require('./renderer.js')
</script>
@yuristrelets
yuristrelets / gist:d88abca500199cff1b50
Last active December 21, 2017 18:07
Get selected record in ExtJS 4.2.1
getSelectedRecord: function() {
var grid = this.getGrid(),
records = grid.getSelectionModel().getSelection(),
record;
if(records.length) {
// get first record from selection
record = records[0];
// find selection record in store
@yuristrelets
yuristrelets / gist:9b543be8cd8af27d0cd9
Last active August 29, 2015 14:01
ExtJS advanced model that is able to update hasMany associations.
/**
* Improved {@link Ext.data.Model}.
* Can automatically update foreign keys and default filter value for hasMany associations.
*/
Ext.define('App.model.AssocModel', {
extend: 'Ext.data.Model',
/**
* @private
* Copies data from the passed record into this record. If the passed record is undefined, does nothing.
@yuristrelets
yuristrelets / gist:8812027
Last active August 29, 2015 13:56
get zodiac sign
function getZodiacSign(date) {
if(!(date instanceof Date)) date = new Date();
var dateStr = +[
date.getMonth() + 1,
('0' + date.getDate()).slice(-2)
].join('')
,signs = [
[120, 'Capricorn'],
[219, 'Aquarius'],
@yuristrelets
yuristrelets / gist:8649122
Created January 27, 2014 14:04
Element in Viewport
function isElementInViewport (el) {
var rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */
rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */
);
}