Skip to content

Instantly share code, notes, and snippets.

View yurimorales's full-sized avatar

Yuri Morales yurimorales

  • Palhoça, SC - Brazil
View GitHub Profile
@yurimorales
yurimorales / fizzBuzz.js
Last active February 17, 2025 19:32
Map Array to FizzBuzz test Javascript
const numbers = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];
const fizzBuzz = (x) => {
if (x % 15 == 0) {
return 'FizzBuzz';
} else if(x % 5 == 0) {
return 'Buzz';
} else if(x % 3 == 0) {
return 'Fizz';
} else {
return '';
@yurimorales
yurimorales / ramdomNumberInterval.go
Created October 11, 2017 20:06
Random Number Go
package main
import (
"fmt"
"math/rand"
"time"
)
func randomNumber(min int, max int) int {
@yurimorales
yurimorales / golang-nuts.go
Created October 17, 2017 13:30 — forked from ryanfitz/golang-nuts.go
two ways to call a function every 2 seconds
package main
import (
"fmt"
"time"
)
// Suggestions from golang-nuts
// http://play.golang.org/p/Ctg3_AQisl
package main
import (
"fmt"
"strings"
)
func reverseString(s string) string {
if len(s) > 0 {
newSlice := strings.Split(s, " ")
@yurimorales
yurimorales / read-long-file.php
Last active March 18, 2024 15:38 — forked from fj/gist:1597544
Slightly nicer way of writing large files to disk with PHP
<?php
// Copy big file from somewhere else
$src_filepath = 'http://example.com/all_the_things.txt'; //$src = fopen($src_filepath, 'r');
$tmp_filepath = '...'; // $tmp = fopen($tmp_filepath, 'w');
$buffer_size = 1024;
while (!feof($src)) {
$buffer = fread($src, $buffer_size); // Read big file/data source/etc. in small chunks
fwrite($tmp, $buffer); // Write in small chunks
}
@yurimorales
yurimorales / .bashrc
Created January 3, 2018 19:45 — forked from marioBonales/.bashrc
Default .bashrc for ubuntu
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
# remove specific file from git cache
git rm --cached filename
# remove all files from git cache
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
$linesIterator = new LimitIterator(
new SplFileObject("filename.txt"),
9, // start at line 10
20 // iterate 20 lines
);
foreach ($linesIterator as $line) {
echo $line; // outputs line 10 to 30
}
$file = new SplFileObject("filename.txt");
$file->seek(9); // so it's line 10
echo $file->current(); // outputs line 10
@yurimorales
yurimorales / Install Gulp.txt
Created June 17, 2018 00:22 — forked from objarni/Install Gulp.txt
Installing gulp in Windows
1. Install nodejs. https://nodejs.org/en/
2. Check npm (node package manager) is installed via command prompt:
$ npm
3. Install gulp:
$ npm install gulp --global
4. In relevant project folder, create 'gulpfile.js':