Skip to content

Instantly share code, notes, and snippets.

View nacmartin's full-sized avatar
👀
👋

Nacho Martín nacmartin

👀
👋
View GitHub Profile
@nacmartin
nacmartin / before-testing.js
Last active September 23, 2019 14:57
Before testing
import * as effects from "redux-saga/effects";
import { END, eventChannel } from "redux-saga";
import * as constants from "../actions/constants";
import io from "socket.io-client";
export function* processTaskTimeConsuming() {
yield effects.delay(3000 + 1000 * Math.random());
}
function* doProcessTask(name) {
@nacmartin
nacmartin / before-channels.js
Created September 23, 2019 08:20
before channels
import * as effects from "redux-saga/effects";
import * as constants from "../actions/constants";
function* processTaskTimeConsuming() {
yield effects.delay(1000 + 1000 * Math.random());
return true;
}
function* doProcessTask(name) {
try {
@nacmartin
nacmartin / beforeall.js
Last active September 24, 2019 15:45
Before all section
import * as effects from "redux-saga/effects";
import * as constants from "../actions/constants";
function* processTaskTimeConsuming() {
yield effects.delay(1000 + 1000 * Math.random());
}
function* doProcessTask(name) {
try {
yield effects.put({ type: constants.TASK_PROCESS_START, name });
@nacmartin
nacmartin / saga-combinators.js
Created September 20, 2019 18:51
Sagas workshop: code at the beginning of combinators
import * as effects from "redux-saga/effects";
import * as constants from "../actions/constants";
function* processTaskTimeConsuming() {
yield effects.delay(1000 + 1000 * Math.random());
}
function* doProcessTask(name) {
try {
yield effects.put({ type: constants.TASK_PROCESS_START, name });
@nacmartin
nacmartin / sagas-infinite-call.js
Created September 20, 2019 16:11
Infinite call
import * as effects from "redux-saga/effects";
import * as constants from "../actions/constants";
function* processTaskTimeConsuming() {
yield effects.delay(1000 + 1000 * Math.random());
if (Math.random() > 0.5) {
return true;
} else {
throw new Error("Something is not right!");
}
@nacmartin
nacmartin / example_indexed_triangles.elm
Created October 26, 2016 19:32
Example of use of IndexedTriangles
import Math.Vector3 exposing (..)
import WebGL exposing (..)
import Html exposing (Html)
import Html.App as Html
import Html.Attributes exposing (width, height, style)
-- Create a mesh with a triangle and a square
type alias Vertex = { position : Vec3 }
@nacmartin
nacmartin / builder.php
Created March 9, 2012 19:38
knpmenu + twitter bootstrap
<?php
class Builder extends ContainerAware
{
public function adminMenu(FactoryInterface $factory, array $options)
{
$menu = $factory->createItem('root');
$menu->setChildrenAttribute('class', 'nav'); //esto es el tema
$menu->setCurrentUri($this->container->get('request')->getRequestUri());
...
@nacmartin
nacmartin / Progressbar.java
Created November 17, 2010 14:10
Java text console progressbar
import java.lang.Math.*;
public class Progressbar {
private int max;
private int current;
private String name;
private long start;
private long lastUpdate;
public Progressbar(int max, String name)
#!/bin/bash
SYMFREPO="git://symfony-git.git.sourceforge.net/gitroot/symfony-git/symfony-git"
DBUSER="root"
DBPASS=""
VENDOR_DIR="lib/vendor/symfony"
if [ -z "$DBPASS" ]; then
echo edit setupsymfony.sh to add your mysql password on line 4: DBPASS=\"password\"
exit