Skip to content

Instantly share code, notes, and snippets.

@maciejkorsan
maciejkorsan / deploy.js
Created Jan 24, 2018
deploy.js script for CircleCI GitHub - FTP upload
View deploy.js
var FtpDeploy = require('ftp-deploy');
var ftpDeploy = new FtpDeploy();
var config = {
username: process.env.FTPUSERNAME,
password: process.env.FTPPASS,
host: process.env.FTPHOST,
port: 21,
localRoot: __dirname + "/../dist/",
remoteRoot: "/",
@maciejkorsan
maciejkorsan / config.yml
Last active Feb 8, 2019
CircleCI GitHub - FTP deploy config
View config.yml
version: 2
jobs:
build:
docker:
- image: circleci/node:latest
steps:
- checkout
- run: npm install
- run: npx gulp build
- run: node .circleci/deploy.js
@krstffr
krstffr / debounced-redux-thunk-action.js
Created Dec 16, 2016
Debouncing redux thunk actions.
View debounced-redux-thunk-action.js
// A common redux pattern when dealing with async functions is to use thunk.
// This usually means your action returns a new function instead of an action object,
// and the thunk middleware will make it all work. Example:
const asyncAction = () => dispatch => setTimeout(() => dispatch(someOtherAction()), 10000);
// Now: maybe that async stuff going on is calling some API which you don't want to overload
// with request, and that's what debounce is for.
// This is an example of a debounced function which will only be calleable once every second.
import { debounce } from 'lodash';
const debouncedFn = debounce(() => callApi(), 1000, { leading: true, trailing: false });
View Tinder_Autoswipe.md
while true; do
    ./adb shell input swipe 100 400 4000 400 400;
done
@standa
standa / HelloNamePage.html.twig
Last active Aug 29, 2015
Symfony Assetic config for minification via uglifyjs and uglifycss
View HelloNamePage.html.twig
{% extends '@YourWhateverNameYouUseBundle/layout.html.twig' %}
{% block body %}
<button class="btn">Hello {{ name }}!</button>
{# example: use for regular assets somewhere deep in your javascripts #}
{# assets:install --env=... has to be run beforehand #}
<script type="text/javascript" src="{{ asset('bundles/yourwhatevernameyouusebundle/js/ckeditor/ckeditor.js') }}"></script>
{% endblock body %}
@sebmarkbage
sebmarkbage / Enhance.js
Last active Apr 23, 2022
Higher-order Components
View Enhance.js
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@branneman
branneman / better-nodejs-require-paths.md
Last active May 13, 2022
Better local require() paths for Node.js
View better-nodejs-require-paths.md

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions