Skip to content

Instantly share code, notes, and snippets.

@mplewis
mplewis / dotabuff_matchup_scraper.ipynb.json
Created January 1, 2014 23:57
Scrape Dotabuff statistics for Dota 2 hero-vs-hero matchup details.
{
"metadata": {
"name": "Dotabuff Scrape Heroes"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@dbayarchyk
dbayarchyk / promiseCatchWithAwait.js
Created October 1, 2019 13:14
Async/await without try/catch in JavaScript
async function fetchAndUpdatePosts() {
const posts = await fetchPosts().catch(() => {
console.log('error in fetching posts');
});
if (posts) {
doSomethingWithPosts(posts);
}
}
@guyellis
guyellis / async.eashSeries.js
Created February 4, 2015 13:38
async.eachSeries()
var async = require('async');
var arr = [1,2,3,4];
async.eachSeries(arr,function(item, cb){
setTimeout(function() {
console.log('#1: ', item);
return cb();
}, Math.random()*2000);
}, function(err){
@keego
keego / screenshot.js
Last active June 9, 2021 19:40 — forked from poissoj/splitImage.js
Uses `html2canvas` to take screenshots each element in an html NodeList, then uses `pdfMake` to concatenate them into a pdf and download it. (ES5 for AngularJS)
// Private fields
var PAGE_HEIGHT = 700;
var PAGE_WIDTH = 500;
// Private methods
function createNewReport (fileName) {
var content = [];
@BlueAccords
BlueAccords / seed.js
Created February 15, 2016 20:31
Seeding mongoose data models with references.
var chai = require('chai'),
sinon = require('sinon'),
expect = chai.expect,
should = chai.should();
var mongoose = require('mongoose');
// var assert = require('assert');
var Studio = require('studioModel');
var User = require('userModel');
@gtzilla
gtzilla / babel.config.js
Created September 14, 2019 12:42
An example of the new babel.config.js.
'use strict'
/**
babel.config.js with useful plugins.
*/
module.exports = function(api) {
api.cache(true);
api.assertVersion("^7.4.5");
const presets = [
[
@fcharlie
fcharlie / profile.json
Last active December 18, 2022 20:38
My Windows Terminal profile.json
// This file was initially generated by Windows Terminal 0.11.1333.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
// You can add more global application settings here.
@boformer
boformer / 0_main.dart
Last active September 3, 2023 19:40
Flutter Service Architecture
import 'package:architecture_playground/home_page.dart';
import 'package:architecture_playground/services.dart';
import 'package:flutter/material.dart';
void main() async {
// perform long-running tasks before "runApp" to display the native splash screen
final services = await Services.initialize();
runApp(ServicesProvider(
services: services,
@jsdevtom
jsdevtom / index.ts
Created July 29, 2018 14:43
Connect to MongoDB from Google Cloud function best practice through Maintaining Persistent Connections
import {CustomError} from "./error/custom-error.interface";
require('dotenv').config();
import {RequestHandler} from 'express';
import {MongoClient} from 'mongodb';
let client: MongoClient;
const connectToClientIfDropped: () => Promise<void> = async () => {
if (client && client.isConnected()) {
@shaunlebron
shaunlebron / _README.md
Last active December 3, 2023 08:58
Direct3D9 Wrapper DLL

In response to a StackOverflow question:

This is code to build a Direct3D wrapper DLL, intercepting all calls to Direct3D interface functions so that you can draw your own objects to display over the game. Just plop the DLL into the same folder as the game's executable, and it should load it as if it were the real d3d9.dll file. It still forwards all calls to the real one in system32, just allows stuff to happen in between. original stackoverflow answer