Skip to content

Instantly share code, notes, and snippets.

View nikolasleblanc's full-sized avatar

Nikolas LeBlanc nikolasleblanc

  • Just Appraised
  • Toronto, Ontario, Canada
View GitHub Profile
@nikolasleblanc
nikolasleblanc / dvc-blocking-App.js
Last active February 9, 2022 15:59
DVC CRA Blocking Example
import logo from './logo.svg';
import './App.css';
import { useDVCVariable } from '@devcycle/devcycle-react-sdk'
const variableKey = 'your variable name'
function App() {
const variable = useDVCVariable(variableKey, false)
return (
<div className="App">
/*
1. Create a new project with create-react-app
2. yarn add @devcycle/devcycle-react-sdk
3. Replace src/App.js with the following
4. enter your envKey and variableKey
*/
import logo from './logo.svg';
import './App.css';
import { useDVCVariable, withDVCProvider } from '@devcycle/devcycle-react-sdk'
import * as React from 'react';
import {
compose,
StateHandler,
StateHandlerMap,
withStateHandlers,
} from 'recompose';
export interface DialogMenuItemProps {
icon?: string;
// example for single field
const validators = {
validatorKey: validatorFunction,
};
function validatorFunction(value): boolean {
return true;
}
const isValid = (value, validatorKeys: Array<string>): boolean => {
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.22.1/ramda.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
@nikolasleblanc
nikolasleblanc / gist:b7680bfa8aa007fd84ffc8a32db613ea
Last active August 23, 2016 17:35
Upgrading to webpack 2
## package.json changes
"webpack": "^2.1.0-beta.20",
"typescript": "^2.0.0",
"webpack-dev-server": "^2.1.0-beta.0",
"webpack-hot-middleware": "^2.12.2",
"webpack-split-by-path": "^0.1.0-beta.1", <-- struggles, I've removed it
https://github.com/BohdanTkachenko/webpack-split-by-path/pull/22#issuecomment-240050461
@nikolasleblanc
nikolasleblanc / middleware.js
Last active August 29, 2015 14:21
Express middleware with additional arguments
function tryThis(myString) {
return function(req, res, next) {
req.heyThere = myString; // should be set to "OH YEAH!"
next();
};
}
app.get("/", tryThis("OH YEAH!"), function(req, res) {
console.log(req.heyThere);
});
@nikolasleblanc
nikolasleblanc / urlParam.js
Created February 24, 2014 15:14
Access querystring from javascript
$.urlParam = function(name, url){
if(!url){
url = window.location.href;
}
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(url);
if (!results)
{
return 0;
}
return results[1] || 0;