Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Coding like a baws

Ricardo Rivas richistron

:octocat:
Coding like a baws
View GitHub Profile
@richistron
richistron / gist:c613e49801b314972db58467ed36b498
Created May 13, 2021 — forked from szydan/gist:b225749445b3602083ed
<U+FEFF> character showing up in files. How to remove them?
View gist:c613e49801b314972db58467ed36b498
1) In your terminal, open the file using vim:
vim file_name
2) Remove all BOM characters:
:set nobomb
3) Save the file:
:wq
@richistron
richistron / generate-ssh-key.sh
Created Nov 4, 2019 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
View generate-ssh-key.sh
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/mozilla_rsa
@richistron
richistron / flatten.ts
Created Feb 18, 2019
flats an array of numbers
View flatten.ts
type arr = number[];
type multiple = number[][];
type irregular = any[];
const flatten = (arr : arr | multiple | irregular) : number[] => {
const newState : number[] = [];
for (let item of arr) {
@richistron
richistron / gist:f4458ae5d810ef24406a3a298c16fc72
Created Jan 6, 2017 — forked from sl4m/gist:5091803
create self-signed certificate for localhost
View gist:f4458ae5d810ef24406a3a298c16fc72
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@richistron
richistron / nginxproxy.md
Created Jul 7, 2016 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?
View nginxproxy.md

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@richistron
richistron / trivia_interval.js
Created Apr 4, 2016
Pregunta de javascript
View trivia_interval.js
// Quiero crear un loop que corra cada 1000 miliseconds, pero que espere a que
// el anterior termine
// incorrecto: http://g.recordit.co/p8ssRrRY27.gif
// correcto: http://g.recordit.co/OFFYS9Nd6F.gif
function doStuff(){
setTimeout(function(){
console.log('done doing stuff');
}, 3000);
};
View gulp_jasmine_browserify_babelify.md

Setup babel + gulp + jasmine + browserify + babelify

ES2015 it's awesome and babel.js is a great tool for compiling ES2015 into javascript code. If you take a look at babel's documentation, you'll find out over than 20 different ways to install babel.js from node to .NET. One of the greatets features in ES2015 is import and export but you can't use it in the browser :( right out of the box. If you want to use modules in the browser you will need to do a trick and use browserify + babelify.

@richistron
richistron / Javascript_FAQS.md
Last active Mar 30, 2016
This was a presentation
View Javascript_FAQS.md

Javascript FAQS

js

How can I create a function which only runs just one time?

I have a method that is running multiple times and I'm not sure why. Since this method does a ajax call, I don't want to fetch the same data twice.

@richistron
richistron / bg-image.scss
Last active Aug 29, 2015
background sass mixin
View bg-image.scss
@mixin bg-image($image) {
// other properties
background-image: image-url($image);
// other properties
}
.myclass {
@include bg-image('asadas.jpg');
}