Skip to content

Instantly share code, notes, and snippets.

if ($elem.scrollTop() + $elem.innerHeight() >= $elem[0].scrollHeight) { console.log(bot scroll reached!); }
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>The HTML5 Herald</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
[alias]
new = "!f() { echo start; git checkout -b $1 --track ${2- origin/Develop}; }; f";
Update-Database -Script –SourceMigration $InitialDatabase
npm version patch -m "Version %s - added more documentationc"
@Drag13
Drag13 / typescript.import.ts
Last active September 3, 2018 15:02
Importing json in typescript
// Fix that gives ability to import json files without TypeScript errors
declare module '*.json' {
const value: any;
export default value;
}
const originalPush = Array.prototype.push;
Array.prototype.push = function newPush() {
console.log('before push');
originalPush.call(this, arguments[0]);
console.log('after push');
}
let x = [];
x.push('a');
function MyArray(arr) {
const _arr = arr || [];
this.push = function push(value) {
console.log('prepush');
_arr.push(value)
console.log('postpush');
}
this.get = function getByIndex(index) {
function spyFactory(array) {
const interceptor = {
get: function (obj, prop) {
if (prop !== 'push') { return obj[prop]; }
return function(...args) {
console.log('prepush');
Array.prototype.push.apply(this, args);
console.log('postpush');
}
function spyFactory(array, prepushHandler, postpushHandler) {
const prepush = functionify(prepushHandler);
const postpush = functionify(postpushHandler);
const interceptor = {
get: function (obj, prop) {
if (prop !== 'push') { return obj[prop]; }
return function (...args) {
prepush(args);
Array.prototype.push.apply(this, args);