Skip to content

Instantly share code, notes, and snippets.

Avatar

Diullei Gomes Diullei

View GitHub Profile
View PrintStgGHC8_4_3.hs
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE StandaloneDeriving #-}
-- | Print STG in GHC 8.4.3.
module Main where
import Control.Monad.IO.Class (liftIO)
import qualified CorePrep
View start-configuration.nix
{ config, pkgs, ... }:
{
imports =
[
./hardware-configuration.nix
];
environment.systemPackages = (with pkgs; [
google-chrome
@Diullei
Diullei / gql2ts.sh
Created Apr 27, 2017
Rudimentary graphql to typescript definition generator. Accepts a graphql schema file (not json, nor js) and converts it to typescript defs.
View gql2ts.sh
#!/usr/bin/env bash
cat "$1" \
| sed -r 's/^(\s*)#/\1\/\//' \
| sed -r 's/!//g' \
| sed -r 's/^input /export interface /g' \
| sed -r 's/^enum /export enum /g' \
| sed -r 's/^type /export interface /g' \
| sed -r 's/^union /export type /g'\
| sed -r 's/^schema /export interface schema /g' \
| sed -r 's/^(\s+[a-zA-Z0-9_-]+\s*)\([^\)]+\)(\s*:\s*)/\1\2/g' \
View test01.ts
abstract class AbstractInternal<T> {
public abstract method(arg: T): void;
}
type InternalCtor<T> = new (param: T) => AbstractInternal<T>;
function createClass<T>(data: T): InternalCtor<T> {
abstract class Internal<T> implements AbstractInternal<T>
{
public constructor(arg: T) {
View Reading configuration files before application startup in Angular2 final release.md

Reading data before application startup in Angular 2

In this demonstration I will show you how to read data in Angular2 final release before application startup. You can use it to read configuration files like you do in other languages like Java, Python, Ruby, Php.

This is how the demonstration will load data:

a) It will read an env file named 'env.json'. This file indicates what is the current working environment. Options are: 'production' and 'development';

b) It will read a config JSON file based on what is found in env file. If env is "production", the file is 'config.production.json'. If env is "development", the file is 'config.development.json'.

View case-insensitive-equals.js
if (typeof(String.prototype.equals) === "undefined") {
String.prototype.equals = function(compare) {
return new RegExp('^' + this + '$', 'i').test(compare);
}
}
// example
"TESTE".quals("teste");
View test-parser.ls
require! [jison, util]
Parser = jison.Parser
_ = (expr) ->
rx = //
^function\s*\(\)\s*\{\s*
(
[\s\S]*
);
@Diullei
Diullei / gt.js
Created Jun 2, 2015
This code will generate a task.json file from your Gruntfile.js and will allow you to run grunt tasks from inside VSCode
View gt.js
/* ****************************************************************************
This code will generate a task.json file from your Gruntfile.js and will
allow you to run grunt tasks from inside VSCode
****************************************************************************
1) Put this file in the same directory of your gruntfile.js (NOTE: must be
the app root directory) run the following command line:
node gt.js
View gist:315a2b2c8e513056edd0
(defn my-last [xs]
(if (= (count xs) 1)
(first xs)
(my-last (rest xs))))
View FizzBuzz.hs
{-
FizzBuzz implementation using Haskell
http://codingdojo.org/cgi-bin/wiki.pl?KataFizzBuzz
-}
fizzBuzz = [
if x `mod` 3 == 0 then
"Fizz"
else
if x `mod` 5 == 0 then