Skip to content

Instantly share code, notes, and snippets.

View xvaldetaro's full-sized avatar

Alexandre Valdetaro xvaldetaro

View GitHub Profile
@xvaldetaro
xvaldetaro / sample.dart
Created September 15, 2014 21:56
shelf sample
import 'package:shelf/shelf_io.dart' as shelf_io;
import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf_route/shelf_route.dart' as shelf_route;
import 'package:shelf_exception_response/exception_response.dart' as shelf_exception;
void main() {
var router = shelf_route.router()
..get('/', (_) => new shelf.Response.ok("Hello World"))
..post('/', (_) => new shelf.Response.ok("Hello World"))
..put('/', (_) => new shelf.Response.ok("Hello World"))
pickSome(z) {
var bool = false;
var i = 0
while (bool == false) {
i++;
y = z[Math.floor(Math.random() * z.length)];
if (i > 500) {
z = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17];
console.log("500 tries already. Allowing any skills.");
}
@xvaldetaro
xvaldetaro / proposal.md
Last active January 28, 2017 01:01
Proposal for a schema for redux

Schema for redux

The idea is to create a schema declaration for redux apps and generate ALL the boilerplate with flow typing. The schema will define the entire hierarchy of the store and the reducers.

What I am trying to achieve here.

  • Greatly reduce boilerplate. Only say your actions and how the state derives from them.
  • Enforce flow typing on everything. Since we have explicit type declaration for the actions, we can generate actions, action creators, reducers and selectors all with the correct types.

I am borrowing the idea from our php repo, which uses gencode heavily to great success.

import type {
MyShape,
MyOtherShape,
} from 'MyTypes';
import type {
ForeignFoo,
} from 'ForeignTypes';
const MyHandlers = require('MyHandlers');
#ifdef _ARM_HAVE_NEON
vDSP_Length vecN = n & ~3u;
for (; (a + i) < (a + vecN); i += 4) {
float32x4_t v = vld1q_f32(a + i);
uint32x4_t vInt = vcvtq_u32_f32(v);
vst1q_u32(c + i, vInt);
}
#endif
for (; (a + i) < (a + n); ++i) {
*(c + i) = (uint32_t)*(a + i);
function rMap(array, callback) {
// seu codigo
}
function rFilter(array, callback) {
// seu codigo
}
function rLength(array) {
return array.length
}
@xvaldetaro
xvaldetaro / Summary.purs
Last active February 17, 2022 17:35
Summary.purs
class Functor f where
map :: forall a b. (a -> b) -> f a -> f b
class (Functor f) <= Apply f where
apply :: ∀ a b. f (a -> b) -> f a -> f b
class (Apply m) <= Bind m where
bind :: ∀ a b. m a -> (a -> m b) -> m b
class (Applicative m, Bind m) <= Monad m
module Main where
import Prelude
import Control.Alt ((<|>))
import Control.Monad.ST.Class (class MonadST, liftST)
import Control.Monad.ST.Ref (new, modify, read)
import Data.Array (cons, fromFoldable)
import Data.Foldable (class Foldable, for_, traverse_)
import Data.Foldable as Foldable
module Main where
import Prelude
import Control.Alt ((<|>))
import Control.Monad.ST.Class (class MonadST, liftST)
import Control.Monad.ST.Internal as Ref
import Control.Monad.ST.Ref as STRef
import Control.Plus (empty)
import Data.Array (cons)