Skip to content

Instantly share code, notes, and snippets.

View jbccollins's full-sized avatar
💭
🐢

James Collins jbccollins

💭
🐢
View GitHub Profile
@scottrippey
scottrippey / Example.js
Created November 8, 2011 20:32
JavaScript that uses a Regex to split a string, ensuring balanced parenthesis and balanced quotes.
var input = "a, b, (c, d), (e, (f, g), h), 'i, j, (k, l), m', 'n, \"o, 'p', q\", r'";
var result = SplitBalanced(input, ",");
// Results:
["a",
" b",
" (c, d)",
" (e, (f, g), h)",
" 'i, j, (k, l), m'",
" 'n \"o, 'p', q\", r'"];
@matt40k
matt40k / GetGeoJSON.sql
Created November 29, 2015 20:57
Turns SQL Server Geography to GeoJSON
CREATE FUNCTION GetGeoJSON (@geo geography)
RETURNS varchar(max)
WITH SCHEMABINDING
/*
* Reference: http://stackoverflow.com/questions/6506720/reformat-sqlgeography-polygons-to-json
*/
AS
BEGIN
DECLARE @Result varchar(max)
SELECT @Result = '{' +
@tduarte
tduarte / publish-ghpages.md
Last active May 18, 2024 13:52
If you need to force push an subtree
git checkout master # you can avoid this line if you are in master...
git subtree split --prefix dist -b gh-pages # create a local gh-pages branch containing the splitted output folder
git push -f origin gh-pages:gh-pages # force the push of the gh-pages branch to the remote gh-pages branch at origin
git branch -D gh-pages # delete the local gh-pages because you will need it: ref
@ravibhure
ravibhure / git_rebase.md
Last active June 25, 2024 13:44
Git rebase from remote fork repo

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:

Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:

git fetch upstream

@nerdyman
nerdyman / resolve-tsconfig-path-to-webpack-alias.js
Last active June 7, 2024 17:16
Convert TypeScript tsconfig paths to webpack alias paths
const { resolve } = require('path');
/**
* Resolve tsconfig.json paths to Webpack aliases
* @param {string} tsconfigPath - Path to tsconfig
* @param {string} webpackConfigBasePath - Path from tsconfig to Webpack config to create absolute aliases
* @return {object} - Webpack alias config
*/
function resolveTsconfigPathsToAlias({
tsconfigPath = './tsconfig.json',
@tokland
tokland / promise_map.js
Last active March 1, 2022 00:18 — forked from anvk/promises_reduce.js
Execute promises sequentially (one at at a time) and return array with the results
function promiseMap(inputValues, mapper) {
const reducer = (acc$, inputValue) =>
acc$.then(acc => mapper(inputValue).then(result => acc.push(result) && acc));
return inputValues.reduce(reducer, Promise.resolve([]));
}
/* Example */
const axios = require('axios');

Upload images to GitHub

  1. Create a new issue on GitHub.

  2. Drag an image into the comment field.

  3. Wait for the upload process to finish.

  4. Copy the URL and use it in your Markdown files on GitHub.

@Mijago
Mijago / armorCalculation.py
Last active July 9, 2024 15:34
Theoretical Destiny 2 armor stat calculator
import configparser
import json
import os.path
import numpy as np
import pulp as pl
####################################################
# THEORETICAL Stat Optimizer by Mijago
# - You tell the script which stats you want (DESIRED_STATS)