Skip to content

Instantly share code, notes, and snippets.

View MrLeebo's full-sized avatar
🤪

Jeremy Liberman MrLeebo

🤪
View GitHub Profile
@MrLeebo
MrLeebo / NoChatHack.user.js
Last active December 17, 2015 13:29
For folks experiencing an issue on Gameglobe with chat not refreshing, a simple javascript patch to fetch chat every 10 seconds.
// ==UserScript==
// @name No Chat Hack
// @namespace http://www.gameglobe.com/
// @version 0.3
// @description For people who have trouble getting chat updates, automatically refreshes the chat window every 10 seconds.
// @match http://www.gameglobe.com/*
// ==/UserScript==
setInterval(function() {
if (unsafeWindow.Bsp.Chat) {
@MrLeebo
MrLeebo / Fixed.cs
Last active December 24, 2015 00:59
Repro of an issue with Syncfusion XlsIO upgrade.
using (var excel = new ExcelEngine())
{
var workbook = excel.Excel.Workbooks.Open(fileName);
var sheet = workbook.Worksheets[sheetName];
var exportWorkbook = excel.Excel.Workbooks.Add(ExcelVersion.Excel2013); // Increases the maximum number of allowed rows.
var exportSheet = exportWorkbook.Worksheets.Create();
exportSheet.IsStringsPreserved = true; // Prevents leading zeroes from being dropped.
sheet.UsedRange.CopyTo(exportSheet.Range["A1"]);
var request = require('request');
var xml2js = require('xml2js');
request('http://example.com/my.xml', function(err, resp, body) {
xml2js.parseString(body, function(err, xml) {
// ...
})
})
............................................________
....................................,.-'"...................``~.,
.............................,.-"..................................."-.,
.........................,/...............................................":,
.....................,?......................................................,
.................../...........................................................,}
................./......................................................,:`^`..}
.............../...................................................,:"........./
..............?.....__.........................................:`.........../
............./__.(....."~-,_..............................,:`........../
assert = require 'assert'
fs = require 'fs'
{ from } = require 'pg-copy-streams'
knex = require './knex' # knex instance with dbConfig
module.exports = (done) ->
runner = new knex.client.Runner(knex.client)
runner.ensureConnection().then (conn) ->
sql = "copy import_data from stdin with csv header null '' delimiter '|' encoding 'windows-1251';"
sqlStream = conn.query(from(sql)).on 'end', ->
module.exports =
swagger: "2.0"
info:
title: "API"
description: "This is my API"
version: "1.0.0"
produces: ["application/json"]
consumes: ["application/json"]
basePath: "/api/v1"
paths:
curl "http://localhost:3000/pets" --data "baz="
@MrLeebo
MrLeebo / Typeahead.jsx
Last active February 4, 2016 16:53
Example using Autosuggest with jquery-ui to fix the suggestions menu position inside a scrollable container
/*global __IS_TEST__*/
import _ from 'lodash';
import React from 'react';
const { array, string, func, number } = React.PropTypes;
import { findDOMNode } from 'react-dom';
import Autosuggest from 'react-autosuggest';
if (!__IS_TEST__) require('jquery-ui');
export default React.createClass({
propTypes: {

Inconsistent Enzyme find Selectors

There is a curious inconsistency between enzyme selectors for shallow rendered components (shallow) and fully rendered components (mount). In order to organize my thoughts, this is a gist describing the issue. First, let's propose a component.

const RepeatDiv = ({depth}) => (<div>{depth > 1 && <RepeatDiv depth={depth-1} />}</div>);

This snippet will define a component called RepeatDiv that will accept a depth prop and will render itself recursively to draw N div elements.

@MrLeebo
MrLeebo / CurrentStyle.jsx
Last active July 25, 2017 19:07
Using async and await to refactor react form components
class MyComponent extends Component {
constructor() {
super()
this.handleFormSubmit = this.handleFormSubmit.bind(this)
this.handleCreateSuccess = this.handleCreateSuccess.bind(this)
this.handleCreateError = this.handleCreateError.bind(this)
}
handleFormSubmit(values) {
return this.props.createModel(values)