Skip to content

Instantly share code, notes, and snippets.

View paulosuzart's full-sized avatar

Paulo Suzart paulosuzart

View GitHub Profile
package com.example.demo.controllers;
import com.example.demo.rating.Limiter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
@RestController("/sample")
stocks = [(24, '2014-01-02'),
(23, '2014-01-03'),
(22, '2014-01-04'),
(26, '2014-01-05'),
(19, '2014-01-06'),
(20, '2014-01-08'),
(25, '2014-01-09'),
(24, '2014-01-10')]
@paulosuzart
paulosuzart / 20180206211408_create_users.cr
Created February 7, 2018 21:32
Migration umable to be run
class CreateUsers::V20180206211408 < LuckyMigrator::Migration::V1
def migrate
create :users do
add name : String
add age : Int32?
end
# Run custom SQL with execute
#
# execute "CREATE UNIQUE INDEX things_title_index ON things (title);"
import * as rp from "request";
import { factory } from "../utils/logger";
import { RequestResponse } from "request";
const logger = factory.getLogger("squadify");
export type Query = {
query: string,
variables: any
type Person {
name: String (λ (root, args, ctx, info)
(surname root))
age: Integer
}
type Query {
# Return all Organizations of an User
{
"vcs_url" : "https://github.com/circleci/mongofinil",
"build_url" : "https://circleci.com/gh/circleci/mongofinil/22",
"build_num" : 22,
"branch" : "master",
"vcs_revision" : "1d231626ba1d2838e599c5c598d28e2306ad4e48",
"committer_name" : "Allen Rohner",
"committer_email" : "arohner@gmail.com",
"subject" : "Don't explode when the system clock shifts backwards",
"body" : "",
from string import ascii_lowercase as lowercase
from string import ascii_uppercase as uppercase
from string import digits, punctuation
from random import randint, sample, shuffle
sources = [lowercase, digits, uppercase, punctuation]
def make_password(length, complexity):
assert(length >= 4)
assert(complexity >= 1 and complexity <= 4)
@paulosuzart
paulosuzart / sample.scala
Created July 11, 2017 04:25
bizarre example with akka http
package com.example
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.server.{HttpApp, Route}
import scala.collection.concurrent.TrieMap
object WebServerHttpApp extends HttpApp with App {
@paulosuzart
paulosuzart / writer.js
Created July 7, 2017 16:58
generation of fake data
const fs = require('fs');
const csvWriter = require('csv-write-stream')
const writer = csvWriter({ headers: ["id", "name"]});
const faker = require('faker');
writer.pipe(fs.createWriteStream('out.csv'))
for (var i = 1; i < 2000000; i++) {
private:
StackContextEntry* getFromContext(StackElements element) {
// as we emplace back in the stack, we should find from back to front
for (auto it = m_stack.rbegin(); it != m_stack.rend(); it++) {
if ((*it).elementType == element) {
return &(*it);
}
}
return NULL;
}