Skip to content

Instantly share code, notes, and snippets.

@yoavniran
yoavniran / mocha-hooks-order.js
Created April 11, 2015 13:35
shows how mocha hooks are ordered and run within contexts
describe("root context", function(){
before(function(){
console.log("before: root");
});
beforeEach(function(){
console.log("beforeEach: root");
});
@yoavniran
yoavniran / Venter.js
Last active May 6, 2024 12:33
a simple pub/sub class for node with support for scopes
/**
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*
* SEE MY venter NPM PACKAGE - https://www.npmjs.org/package/venter
* OR REPOSITORY ON GITHUB - https://github.com/yoavniran/node-venter
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@yoavniran
yoavniran / selector.js
Last active May 6, 2024 12:33
function to select element even using a numeric class name on IE8
var _selectorRgx = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/ ; //stole from jquery, to be used to quicken selector if simple class/id/tag selector used
/**
* stole the regex logic from jquery, added the support for classname selector starting with a number on IE8
* for example selector = ".1111" will work with this code even on IE8
**/
function select(selector) {
var match = _selectorRgx.exec(selector),
doc = window.document,
@yoavniran
yoavniran / SimpleAuthTransporter.js
Last active May 6, 2024 12:33
class used to allow making authorized requests to google API that also allows streaming the response even if a token refresh is required
"use strict";
var util = require("util"),
_ = require("underscore"),
events = require("events"),
request = require("request"),
AppAuthClient = require("../google/AppAuthClient"); //thin wrapper around the google oauth2client - simply initializing it with app's client id and secret
var SimpleAuthTransporter= (function () {
@FikretHassan
FikretHassan / report-ads-to-slack.js
Last active May 6, 2024 12:32
report-ads-to-slack.js
/*
This is outdated, for the up to date version see:
https://github.com/FikretHassan/report-ads-to-slack-chrome-extension/blob/main/Ad%20Feedback%20Toggle%20Extension/adtech.js
*/
window.top.googletag.cmd.push(function() {
window.top.adentify = window.top.adentify || {};
window.top.adentify.about = { // deatils about this version of the code
version: '0.1',
@yoavniran
yoavniran / convertFromGridToInfiniteProps.js
Last active May 6, 2024 12:32
convert data from react-window Grid's onItemsRendered to data that react-window-infinite-loader's onItemsRendered understands
onItemsRendered = (gridData: Object) => {
const {useOverscanForLoading} = this.props; //default is true
const {
visibleRowStartIndex,
visibleRowStopIndex,
visibleColumnStopIndex,
overscanRowStartIndex,
overscanRowStopIndex,
overscanColumnStopIndex
@abothun
abothun / SassMeister-input-HTML.html
Last active May 6, 2024 12:31
Generated by SassMeister.com.
<header id="siteHeader" class="defaultHead">
Header
</header>
<div id="siteContainer">
<div id="siteContent" class="twoColumn">
<section id="upperMainColumn" role="main" class="contentWell">
UpperMain
</section>
<aside id="upperRightColumn">upper right. Must be 300px wide</aside>
@yoavniran
yoavniran / CustomImagePreview.jsx
Last active May 6, 2024 12:31
React-Uploady preview with progress demo - CustomImagePreview.jsx
import styled from "styled-components"
import { useItemProgressListener } from "@rpldy/uploady";
const PreviewImage = styled.img`
margin: 5px;
max-width: 200px;
height: auto;
transition: opacity 0.4s;
${({ completed }) => `opacity: ${completed / 100};`}
@ihor-lev
ihor-lev / sublime_fix_home_end_keys.md
Last active May 6, 2024 12:31
Fix Sublime Text Home and End key usage on Mac OSX

Sublime Text Home/End keys default functionality jumps to the beginning and end of the file.

Fix Home and End keys to move the cursor to the beginning and end of lines.

Preferences > Key Bindings - User

Adding the following to the array:

{ "keys": ["home"], "command": "move_to", "args": {"to": "bol"} },
{ "keys": ["end"], "command": "move_to", "args": {"to": "eol"} },
@onatcipli
onatcipli / go_router_example.dart
Last active May 6, 2024 12:29
go_router_example.dart
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
main() {
CustomNavigationHelper.instance;
runApp(const App());
}
class App extends StatelessWidget {
const App({Key? key}) : super(key: key);