Skip to content

Instantly share code, notes, and snippets.

@tomaskikutis
tomaskikutis / app.tsx
Created September 20, 2015 19:01
react typescript browserify
// npm install browserify -g
// npm install tsd -g
// npm install react tsify
// tsd install react
// browserify app.tsx -p [tsify --jsx=react] -o bundle.js
/// <reference path="typings/react/react.d.ts" />
import React = require("react");
interface HelloWorldComponentProps extends React.Props<any> {
NAME=$(git branch | grep '*' | sed 's/* //')
DESCRIPTION=$(git config branch."$NAME".description)
TEXT=$(cat "$1" | sed '/^#.*/d')
if [ -n "$TEXT" ]
then
echo "$NAME"': '$(cat "$1" | sed '/^#.*/d') > "$1"
if [ -n "$DESCRIPTION" ]
then
echo "" >> "$1"
const assertValidEmail = (value, errorMessage) => {
const pattern = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (!pattern.test(value)) {
throw new Error(errorMessage || translator('error.email.malformatted', { email: value}));
}
};
const assertAvailableEmail = async (value) => {
return fetch('/validate_email', {
@sauldeleon
sauldeleon / 1.SomeComponent.stories.js
Last active September 5, 2020 12:36
Storybook meets axios meets redux meets thunk
/**
This is my workarround to create a React Story for a component which internally dispatch multiple thunk actions
and also retrieve info from some server. This works also on making an story in which its main component wraps another redux
connected components.
*/
/**
BEHAVIOUR EXPLANATION
This component depends on an ID (fetchingDataId) which is stored in the parent component which contains many SomeComponents, so I need to mock the store before SomeComponent's story loads
Then, when a single SomeComponent loads, it renders two connected subcomponents which I dont have control from Storybook. And I want the story to render both components at the same time.
@adamcbrewer
adamcbrewer / viewbox-trim.js
Last active February 5, 2021 09:06
JS: Trim SVG viewbox
/**
* Will trim the whitespace around the SVG's viewbox
*
*/
var svg = document.getElementsByTagName("svg")[0];
var bbox = svg.getBBox();
var viewBox = [bbox.x, bbox.y, bbox.width, bbox.height].join(" ");
svg.setAttribute("viewBox", viewBox);
@developit
developit / README.md
Last active March 21, 2022 21:32
Webpack Starter Template

Webpack Starter Template

This is a basic Webpack project template for a web app written in ES6 & LESS.

This assumes you have a directory structure as follows:

package.json
webpack.config.js
src/
@sam-artuso
sam-artuso / setting-up-babel-nodemon.md
Last active November 3, 2023 08:52
Setting up Babel and nodemon

Setting up Babel and nodemon

Inital set-up

Set up project:

mkdir project
cd project
npm init -y
@frzsombor
frzsombor / gist:ddd0e11f93885060ef35
Last active December 7, 2023 00:05
Share Laravel's session and check authentication from external projects
<?php
/*
|--------------------------------------------------------------------------
| Sharing Laravel's session and checking authentication
|--------------------------------------------------------------------------
|
| Use the following code in any CMS (WordPress, Joomla, etc), filemanager (CKFinder,
| KCFinder, simogeos's Filemanager, etc), or any other non-Laravel project to boot into
| the Laravel framework, with session support, and check if the user is authenticated.
anonymous
anonymous / app.dockerfile
Created January 2, 2017 11:02
FROM php:7.0.4-fpm
RUN apt-get update && apt-get install -y libmcrypt-dev \
mysql-client libmagickwand-dev --no-install-recommends \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
&& docker-php-ext-install mcrypt pdo_mysql