Skip to content

Instantly share code, notes, and snippets.

View gwendall's full-sized avatar
🏠
Working from home

gwendall gwendall

🏠
Working from home
View GitHub Profile
@gwendall
gwendall / FixedSizeListSimpleBar.tsx
Created January 14, 2023 18:04
FixedSizeList + SimpleBarReact
import SimpleBarReact from 'simplebar-react';
import { FixedSizeList } from 'react-window';
import React from 'react';
const FixedSizeListSimpleBar: React.FC<typeof FixedSizeList & {
className?: string;
height?: number;
children: React.ReactNode;
}> = ({
className,
@gwendall
gwendall / webpack.config.js
Created July 18, 2019 15:12
create-react-app 3.0.1 - Webpack config
'use strict';
const fs = require('fs');
const isWsl = require('is-wsl');
const path = require('path');
const webpack = require('webpack');
const resolve = require('resolve');
const PnpWebpackPlugin = require('pnp-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
@gwendall
gwendall / gist:39368ad6dc1e3f87adaa
Created April 28, 2015 13:14
jQuery animation end callback
/*
$(".some-selector").onAnimationEnd(function(animationName) {
console.log(" Will be called when any of the show or hide animations end.");
}, ["show", "hide"]);
*/
$.fn.onAnimationEnd = function(callback, animationName) {
var animations = ["animationend", "oAnimationEnd", "MSAnimationEnd", "webkitAnimationEnd"];
$(document).delegate(this.selector, animations.join(" "), function(e) {
var ev = e.originalEvent || e
@gwendall
gwendall / gist:d5832a77014399ffadab
Last active August 29, 2015 14:16
Safe javascript variables
/*
Returns a nested property / executes a nested function from a variable, or a default value, without having it throwing any error
*/
var safeVar = function(string, def) {
var properties = string.split(".");
var filtered = [];
try {
properties.forEach(function(property) {
filtered.push(property);
@gwendall
gwendall / gist:c9e292792b5bbb904da3
Last active August 29, 2015 14:16
Hijack callback for any function
/*
Takes any function with a callback as last parameter, and allow to add it another callback executed before it. Requires underscore.
Example:
Mongo.Collection.prototype.insert = extendWithCallback(Mongo.Collection.prototype.insert, function() {
console.log("This logs every time an insert is done on a collection, even though we did not explicitely declared a callback when calling insert");
});
var items = new Mongo.Collection("items");
@gwendall
gwendall / gist:35787d6a74763f218f92
Created February 26, 2015 13:12
Simple Javascript async each loop
/*
Prevents browsers from crashing with heavy loops
*/
eachAsync = function(array, iterator, callback) {
var timeout = 0;
var counter = 0;
function process() {
iterator.apply && iterator.apply(this, [counter, array[counter]]);
counter += 1;
if (counter < array.length) {
@gwendall
gwendall / gist:a19043795a6263865007
Created December 11, 2014 15:58
Gem install error (Yosemite)
ERROR: Loading command: install (LoadError)
dlopen(/usr/local/Cellar/ruby/2.1.2_1/lib/ruby/2.1.0/x86_64-darwin14.0/openssl.bundle, 9): Symbol not found: _SSLv2_client_method
Referenced from: /usr/local/Cellar/ruby/2.1.2_1/lib/ruby/2.1.0/x86_64-darwin14.0/openssl.bundle
Expected in: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
in /usr/local/Cellar/ruby/2.1.2_1/lib/ruby/2.1.0/x86_64-darwin14.0/openssl.bundle - /usr/local/Cellar/ruby/2.1.2_1/lib/ruby/2.1.0/x86_64-darwin14.0/openssl.bundle
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
var loggedIn = false;
Meteor.autorun(function() {
var user = Meteor.user();
if (user) {
if (!loggedIn) {
loggedIn = true;
/* Login callback */
}
} else {
if (loggedIn) {
Posts = new Mongo.Collection("posts");
if (Meteor.isServer) {
Meteor.publish("posts", function(timeStamp) {
var selector = timeStamp ? { createdAt: { $gte: timeStamp }} : {};
var options = timeStamp ? {} : { limit: 10, sort: { createdAt: -1 }};
return Posts.find(selector, options);
});
}
@gwendall
gwendall / helper.js
Last active August 29, 2015 14:05
Helper that brings Underscore directly in Meteor Templates
UI.registerHelper('_', function() {
arguments = _.toArray(arguments);
var self = this,
fn = arguments[0];
arguments.shift(); // Removes the Underscore function
arguments.pop(); // Remove the Spacebars appended argument
return _[fn].apply(self, arguments);
});
/*