Skip to content

Instantly share code, notes, and snippets.

@urielhdz
urielhdz / main.rb
Last active August 29, 2015 14:16
#RetasProgramacion 1
# Evaluar archivo por cada 3 líneas
# La primera linea representa la cantidad de casos
# Evaluar el crédito C primera linea
# Evaluar la cantidad de elementos l
# Almacenar en un arreglo la cantidad de elementos
def execute_solution lines
lines.size == 3 ? inner_execution(lines) : false
end
@urielhdz
urielhdz / gist:dba98dfb9aec70156718
Created March 17, 2015 03:12
Upload video to GCS using Fog and PaperClip
module HasVideoConcern
extend ActiveSupport::Concern
included do
has_attached_file :mp4_video_file,
:storage => :fog,
:fog_credentials => {
provider: 'Google',
google_storage_access_key_id: '',
google_storage_secret_access_key: ''
},
@urielhdz
urielhdz / hash_table.go
Last active October 8, 2015 17:56
Hash Table using Go
package main
import(
"fmt"
"math"
"bufio"
"os"
"strings"
)
type HashEntry struct{
package main
import(
"fmt"
"strconv"
)
type Node struct {
right *Node
left *Node
parent *Node
value int
package main
import(
"fmt"
)
func main() {
arr := []int{31, 41, 59, 26, 53, 58, 97, 93, 23, 84,1}
quick_sort(&arr,0,len(arr)-1) //Initialize with 0 as left and length - 1 as right
fmt.Println(arr) //Sorted array
package main
import(
"fmt"
"strconv"
)
type Node struct{
value int
right *Node
left *Node
package main
import(
"fmt"
)
func main() {
// TEST
arr := []int{31, 41, 59, 26, 53, 58, 97, 93, 23, 84,1,100,5,23}
fmt.Println(merge_sort(arr))
}
function urlBase64ToUint8Array(base64String) {
const padding = '='.repeat((4 - base64String.length % 4) % 4);
const base64 = (base64String + padding)
.replace(/\-/g, '+')
.replace(/_/g, '/');
const rawData = window.atob(base64);
const outputArray = new Uint8Array(rawData.length);
for (let i = 0; i < rawData.length; ++i) {
@urielhdz
urielhdz / pares_con_ciclos.js
Created June 28, 2017 21:58
Obtener pares de ciclos
let arreglo [1,2,3,4,5];
let newArreglo = [];
for(var i = 0;i < arreglo.length; i++){
if(arreglo[i] % 2 == 0) newArreglo.push(arreglo[i]);
}
@urielhdz
urielhdz / pares_con_filter.js
Created June 28, 2017 22:06
Pares con filter
let arreglo = [1,2,3,4,5];
let newArreglo = arreglo.filter((numero) => numero % 2 == 0 );