Skip to content

Instantly share code, notes, and snippets.

View jgatjens's full-sized avatar
🏠
working from home!

Jairo Gätjens jgatjens

🏠
working from home!
View GitHub Profile
@jgatjens
jgatjens / shadowem
Created October 23, 2019 05:12
C++ exercises
#include<stdio.h>
#include<math.h>
void one_thousand_square();
void fx();
void multiplication_table();
void factorial();
int main() {
int n, opcion;
@jgatjens
jgatjens / random.js
Created May 12, 2018 18:55
Ramdon Number
function randomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
@jgatjens
jgatjens / flatten-array.js
Last active September 21, 2017 17:17
flatten an array of arbitrarily nested arrays
/**
* Flatten an Array of Arbitrarily nested Arrays of Integers
* @param {Array} integers_array - Array of Numbers
* @param {Array} flatten_array - Flatten array of Numbers
* @return {Array} - Array of Numbers
*/
var flatten = function(integers_array, flatten_array) {
// If this function is called in recursion
// need to keep previous recursion results.
@jgatjens
jgatjens / web.config
Created May 3, 2017 18:30
.Net config for SPA's
<?xml version="1.0" encoding="UTF-8"?>
<!-- Environment: Stage -->
<configuration>
<connectionStrings>
</connectionStrings>
<appSettings>
</appSettings>
<system.web>
<compilation debug="false" targetFramework="4.0"/>
</system.web>
@jgatjens
jgatjens / .htaccess
Created May 3, 2017 07:38
Apache config for SPA's
# To be inside the /webroot
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
@jgatjens
jgatjens / sendemail.js
Last active February 12, 2020 00:51
Node and Gmail
if (process.env.GMAIL_PASS) {
var fromEmail = 'username@gmail.com';
var fromPassword = process.env.GMAIL_PASS;
var toEmail = [
'user1@domain.com',
'client2@domain.com'
];
@jgatjens
jgatjens / go prod ftp
Created July 26, 2016 05:22
Upload folder to a FTP using lftp command.
#!/bin/bash
read -p "Are you sure you want to go to production? <y/N> " prompt
if [[ $prompt =~ [yY](es)* ]]
then
echo "---- UPDATE example.net SITE ----"
HOST="ftp.example.net"
USER="username"
PASS="password"
FTPURL="ftp://$USER:$PASS@$HOST"
LCD="/Users/username/Sites/project-name"
@jgatjens
jgatjens / FTP - lftp
Created July 26, 2016 05:19
change permission to a group of files over FTP terminal using lftp command
#!/bin/bash
echo "---- UPDATE PERMISSION example.net IMAGES ----"
HOST="ftp.example.net"
USER="usernmae"
PASS="password"
FTPURL="ftp://$USER:$PASS@$HOST"
lftp <<EOF
set ftp:ssl-allow no
set ftp:passive-mode true
set ftp:list-options -a
@jgatjens
jgatjens / steps.js
Last active April 8, 2016 03:45
Format object with loadash and reduce, format by day, formay by month, groupby and sum by dates.
/*
weekly = [
['3/6 - 3/12', 10],
['3/12 - 3/19', 13]
];
day = [
['3/6', 10]
['3/8', 2]
];
@jgatjens
jgatjens / index.js
Last active February 13, 2018 11:37
Javascript regex match images path in JSON or string.
var regMatch = new RegExp("http:\\/\\/\[^\"]+(.png|.jpg|.gif|.jpeg)","gi");
var str = JSON.stringify(data);
ARRAY_IMAGES = str.match(regMatch);
console.log(ARRAY_IMAGES);