Skip to content

Instantly share code, notes, and snippets.

@klzns
klzns / _index.js
Created December 21, 2015 20:52
ISO Alpha 3 to country name localized. Translated country names in Portuguese, spanish, french and english.
var fs = require('fs');
// Files
var files = [
'es',
'fr',
'pt-br',
'us'
];
@klzns
klzns / plainChars.coffee
Created April 22, 2013 14:41
Function that removes all accentuation from a string (based on Underscore String)
plainChars = (str) ->
if not str? then return throw(new Error("plainChars needs a param"))
specialChars = "ąàáäâãåæćęèéëêìíïîłńòóöôõøśùúüûñçżź"
plain = "aaaaaaaaceeeeeiiiilnoooooosuuuunczz"
regex = new RegExp '[' + specialChars + ']', 'g'
str += ""
str.replace regex, (char) -> plain.charAt (specialChars.indexOf char)
@klzns
klzns / gist:5066139
Last active December 14, 2015 09:38 — forked from tzi/index.html
Detect Internet Explorer version in Coffeescript. Returns IE version number if true, otherwise returns false.
window.dammitIE = do ->
is_internet_explorer = ->
window.navigator.appName is "Microsoft Internet Explorer"
get_internet_explorer_version = ->
matches = new RegExp(" MSIE ([0-9].[0-9]);").exec(window.navigator.userAgent)
return parseInt(matches[1].replace(".0", "")) if matches? and matches.length > 1
true
@klzns
klzns / mac-and-ubuntu-node-install.sh
Last active November 18, 2015 16:05
Node install instructions
#!/bin/bash
echo 'Installing node latest stable'
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=$HOME/local
@klzns
klzns / conemu-gitbash.md
Last active September 14, 2015 21:21
ConEmu & Git Bash

You can get to the settings by right-clicking the window bar (why this isn't on a [gear] icon is beyond me). If you want it to take over as the default command prompt, the option you want is under Integration > Default Term, its the first checkbox.

Now, to get the MySysGit Bash to open:

  1. Go to Startup > Tasks
  2. Hit the [+] Button to create a new task
  3. Give it a name
  4. Set the task parameters to /single /Dir "[YourStartupDir]" /icon "%ProgramFiles(x86)%\Git\etc\git.ico"
  5. Set the shell with the command
@klzns
klzns / setup.md
Last active September 14, 2015 21:20
Setup Storefront

Para o Alpha precisamos que o computador tenha algumas coisas instaladas. Caso não consiga instalar algo, podemos ver isso no dia.

Node

Instruções de como instalar o node.

Windows

Caso use o Windows, instale o Git Bash e o ConEmu eles facilitam o uso do terminal. Depois configure o ConEmu para usar o Git Bash (instruções)

Pacotes node

@klzns
klzns / gist:a8f83b0de7a899b61b06
Last active August 29, 2015 19:30
Como pegar a URL da imagem do produto
let accountName = 'basedevmkp';
let width = 500;
let height = 500;
let path = imageUrl.replace('#width#', width).replace('#height#', width);
let baseUrl = `http://${accountName}.vteximg.com.br`
path = baseUrl + path;
@klzns
klzns / ReactSVGWebpackExample.jsx
Last active August 29, 2015 14:27 — forked from MoOx/svgicon.css
Adding SVG icons with React + webpack
import React from 'react';
import SVGIcon from 'components/utils/SVGIcon';
import myIcon from 'assets/icons/myicon.svg';
class MyComponent extends React.Component {
render() {
return (
<div>
<SVGIcon svg={myIcon} width={18} height={18} fill="#444"/>
</div>
@klzns
klzns / c#.cs
Last active August 29, 2015 14:06
Validação de RUC do Peru
private bool ValidateRUC(string ruc)
{
if (Regex.IsMatch(ruc, "^[0-9]{11}$|^[0-9]{8}$"))
{
//converte o array de caracteres em um array de inteiros
int[] intArray = new int[ruc.Length];
for (int i = 0; i < ruc.Length; i++)
{
intArray[i] = Convert.ToInt32(ruc[i].ToString());
}
@klzns
klzns / Array of Coordinates Regex.md
Last active August 29, 2015 14:05
Regular Expression for an array of coordinates

Regex

\[(?:\[(?:(?:-|)\d+?(?:(?:\.\d+?|))\,(?:(?:-|)\d+?(?:(?:\.\d+?|))))\](?:\,(?!\])|))+?\]

Sample input

[[-80.190262,25.774252],[-66.118292,18.466465],[-64.75737,32.321384],[-80.190262,25.774252]]