Skip to content

Instantly share code, notes, and snippets.

View ivportilla's full-sized avatar

Ivan Portilla ivportilla

View GitHub Profile
import scala.util._
import akka.actor._
import akka.stream._
import akka.stream.scaladsl._
import akka.util._
object SimpleTcpServer extends App {
val address = "127.0.0.1"
import java.awt.Dimension
import java.awt.event.MouseAdapter
import java.awt.event.MouseEvent
import javax.swing.JFrame
import scala.collection.immutable
import scala.concurrent.duration._
import akka.actor._
import akka.stream._
/* Data definition */
trait DocumentInfo {
val title: String
}
case class D1(title: String, content: String) extends DocumentInfo
case class D2(title: String, count: Int) extends DocumentInfo
/* -------------- */
/* Type Class */
case class Dni(src: String, parsed: String) {
override def equals(obj: scala.Any): Boolean = obj match {
case dni: Dni => dni.src == src || dni.parsed == parsed
case dni: String => dni == src || dni == parsed
case _ => false
}
override def toString: String = src
}
const path = require('path');
const webpack = require('webpack');
const apiHost = require('./src/config/deploy.config');
module.exports = {
entry: './src/frontend/app/index.js',
output: {
path: path.resolve(__dirname, './src/frontend/dist'),
filename: 'bundle.js'
},
-module(submission).
-export([bits/1, bitsTail/1, area/1, perimeter/1, enclose/1]).
% Direct recursive definition of bits func.
bits(0) -> 0;
bits(1) -> 1;
bits(N) when (N > 1) -> N rem 2 + bits(N div 2).
% Tail version of the bits func.
bitsTail(N) -> bitsTailIt(N, 0).
-module(vars_and_patterns).
-export([xOr1/2, xOr2/2, xOr3/2, maxThree/3, howManyEqual/3]).
xOr1(X, Y) when X and Y ->
false;
xOr1(X, Y) when not(X or Y) ->
false;
xOr1(_, _) -> true.
xOr2(X, Y) when X == Y ->
@ivportilla
ivportilla / test.scala
Created February 16, 2017 20:47
Blocking future test
test("blocking in Future") {
var threadsBlock: mutable.Set[String] = scala.collection.mutable.Set()
var threads: mutable.Set[String] = scala.collection.mutable.Set()
def currentThread = Thread.currentThread().getName
/*def nonBlockingFuture = Future{
threads += currentThread
Thread.sleep(1000)
}*/
POST /authentication
body: {
"access_token": "kjbILH7hl8hpbyPBUP9...",
"strategy": "facebook"
}
RESPONSE:
{
"access_token": "....."
@ivportilla
ivportilla / DEBUG LOG
Last active January 3, 2017 04:19
Feathers auth error
feathers-authentication-local:verify Checking credentials +2ms i@sapcosdfsdf.co abc1234
feathers-authentication:passport:authenticate Authentication strategy 'local' failed +20ms undefined undefined
error: (401) Route: /authentication - Error
info: NotAuthenticated: Error
at NotAuthenticated.ExtendableBuiltin (/home/ivcp/Documents/Sapco/mobi-backend/node_modules/feathers-errors/lib/index.js:21:28)
at NotAuthenticated.FeathersError (/home/ivcp/Documents/Sapco/mobi-backend/node_modules/feathers-errors/lib/index.js:96:116)
at new NotAuthenticated (/home/ivcp/Documents/Sapco/mobi-backend/node_modules/feathers-errors/lib/index.js:149:117)
at /home/ivcp/Documents/Sapco/mobi-backend/node_modules/feathers-authentication/lib/hooks/authenticate.js:79:31
at process._tickCallback (internal/process/next_tick.js:103:7)