Skip to content

Instantly share code, notes, and snippets.

View n3dst4's full-sized avatar
:octocat:
fgdxgfdxfg

Neil de Carteret n3dst4

:octocat:
fgdxgfdxfg
View GitHub Profile
@n3dst4
n3dst4 / disable-chrome-same-origin.md
Created June 4, 2018 10:38
How to disable same-origin policy (aka CORS checking) in Chrome

You need to run Chrome with two command line flags:

--disable-web-security --user-data-dir

These are kind of documented here: https://peter.sh/experiments/chromium-command-line-switches/

--disable-web-security is the one that turns off the same-origin policy (the name is scarier than the action). Although the docs don't say this, this flag is ignored unless you also specify --user-data-dir. That's because --disable-web-security can be super risky so you shouldn't be surfing in that mode all the time, so Chrome requires you to use an alternative user profile, specified with --user-data-dir. However, you can get away with just giving --user-data-dir and not specifying a dir, and it will use the default one (so you get all your bookmarks, cookies, extension, etc. but --disable-web-security will still feel that honour has been satisfied and tuirn off same-origin policy.

@n3dst4
n3dst4 / enable_ms_store.reg
Created March 29, 2018 13:21
How re-enable MS Store if your overzealous local IT have tried to disable it
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsStore]
"RemoveWindowsStore"=dword:00000000
@n3dst4
n3dst4 / switchy.js
Last active July 7, 2016 07:13
let + switch
// What is the console output of this code?
function switchFoo (foo) {
switch (foo) {
case 1:
foo = 5
console.log(foo)
case 2: {
console.log(foo)
break

1️⃣

🐦🍐🌳

2️⃣

🐢🐦 🐢🐦

🐦🍐🌳

@n3dst4
n3dst4 / renaming.markdown
Last active January 13, 2025 16:46
How to rename Visual Studio solutions and projects

How to rename solutions and projects in Visual Studio

  1. Don't.

How to rename solutions and projects that were created in Visual Studio

  1. Close Visual Studio and don't open it again until I tell you. Visual Studio is not competent at renaming things.
  2. Assuming you're using git, clean the working folder to remove anything that's not in version control (this will help the search-and-replace step because it won't have to go through a bunch of generated files)

git clean -fdx

@n3dst4
n3dst4 / dw-sorter.clj
Created August 2, 2015 16:22
DW sorter
(defn episode-number [file]
(def match (re-matches
#"\d{4}-\d{2}-\d{2} - (S\d\d E\d\d) - .*"
(.getName file)))
(if (= match nil)
nil
(match 1)))
(def episodes (partition-by episode-number files))
@n3dst4
n3dst4 / browserify_transforms.markdown
Created September 22, 2014 07:52
Troubleshooting how Browserify transforms get applied (i.e. why isn't my code getting processed by Reactify?)

If you're using Browserify and Reactify to write React components and build them for the browser, you may, depending on your setup, see errors along the lines of "unexpected token <", which means that your code is not getting Reactified properly. You will either see this in Gulp, because some subsequent step in the pipeline can't parse your code, or in the browser.

Here's how browserify decides how to apply transforms:

  1. Anything specified when you actually call browserify (i.e. in a gulpfile or on the command line) will be run first. Calls here can specify {global: true}, which will make them be applied to dependencies as well as code in the current module.
  2. If there is a browserify.transform key in package.json, it can list transforms which should be applied, in the order that they should be applied.

You need to specify reactify before anything else which is going to want to parse the code, because obvs. it isn't valid es5 until it's been reactified (so e.g. having `["browserify-shim", "reactify"

@n3dst4
n3dst4 / ConEmu Git Bash.md
Last active October 20, 2024 23:59
My ConEmu / Cmder git bash task config
  1. Open Conemu

  2. Open Settings -> Tasks or go to new tab button -> Setup tasks.

  3. Click + to add a new task

  4. Enter the name as Git Bash or whatever you like

  5. Task parameters:

     /icon "C:\Program Files (x86)\Git\etc\git.ico" /dir "C:\_git"
    
  6. Command:

@n3dst4
n3dst4 / gulpfile.js
Created August 13, 2014 12:09
A gulp task that runs "npm install" with options passed thru from command line
gulp.task("install", function(cb) {
var npm = require("npm");
npmConfig = {};
// sample command line opts, you may have others
if (gUtil.env["npm-cache-path"]) npmConfig.cache = gUtil.env["npm-cache-path"];
if (gUtil.env["npm-log-level"]) npmConfig.loglevel = gUtil.env["npm-log-level"];
npm.load(npmConfig, function (er) {
if (er) return cb(er);
npm.commands.install([], function (er, data) { cb(er); });
@n3dst4
n3dst4 / requireTime.js
Created August 13, 2014 08:15
Time how long all your require()s take
/*
* requireTime.js
*
* require()s every thing in your node_modules and tells you how long each one
* took.
*
* USAGE:
* $ cd your_project_folder
* $ node loadTest.js
*