Skip to content

Instantly share code, notes, and snippets.

View Diullei's full-sized avatar

Diullei Gomes Diullei

View GitHub Profile

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@Diullei
Diullei / PrintStgGHC8_4_3.hs
Created December 6, 2020 18:09 — forked from chrisdone/PrintStgGHC8_4_3.hs
Print STG in GHC 8.4.3
{-# 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
{ config, pkgs, ... }:
{
imports =
[
./hardware-configuration.nix
];
environment.systemPackages = (with pkgs; [
google-chrome
@Diullei
Diullei / gql2ts.sh
Created April 27, 2017 20:39
Rudimentary graphql to typescript definition generator. Accepts a graphql schema file (not json, nor js) and converts it to typescript defs.
#!/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' \
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) {

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'.

if (typeof(String.prototype.equals) === "undefined") {
String.prototype.equals = function(compare) {
return new RegExp('^' + this + '$', 'i').test(compare);
}
}
// example
"TESTE".quals("teste");
require! [jison, util]
Parser = jison.Parser
_ = (expr) ->
rx = //
^function\s*\(\)\s*\{\s*
(
[\s\S]*
);
@Diullei
Diullei / gt.js
Created June 2, 2015 20:49
This code will generate a task.json file from your Gruntfile.js and will allow you to run grunt tasks from inside VSCode
/* ****************************************************************************
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
(defn my-last [xs]
(if (= (count xs) 1)
(first xs)
(my-last (rest xs))))