Skip to content

Instantly share code, notes, and snippets.

@zaloogarcia
zaloogarcia / pandas_to_spark.py
Last active April 19, 2022 16:20
Script for converting Pandas DF to Spark's DF
from pyspark.sql.types import *
# Auxiliar functions
# Pandas Types -> Sparks Types
def equivalent_type(f):
if f == 'datetime64[ns]': return DateType()
elif f == 'int64': return LongType()
elif f == 'int32': return IntegerType()
elif f == 'float64': return FloatType()
else: return StringType()
@ryboe
ryboe / .travis.yml
Last active November 23, 2023 05:37
Example .travis.yml for Golang
# use the latest ubuntu environment (18.04) available on travis
dist: bionic
language: go
# You don't need to test on very old versions of the Go compiler. It's the user's
# responsibility to keep their compiler up to date.
go:
- 1.16.x
let webpack = require('webpack');
let path = require('path');
module.exports = {
entry: {
app: './resources/assets/js/app.js',
vendor: ['vue', 'axios']
},
output: {
import {Injectable} from '@angular/core';
import {FirebaseAuth, AngularFire} from "angularfire2";
import {Subject, Observable, BehaviorSubject} from "rxjs";
import {AuthInfo} from "./auth-info";
@Injectable()
export class AuthService {
static UNKNOWN_USER = new AuthInfo(null);
authInfo$: BehaviorSubject<AuthInfo> = new BehaviorSubject<AuthInfo>(AuthService.UNKNOWN_USER);
@prabod
prabod / randomPopulation.js
Created December 3, 2016 19:09
Random Population
/**
* Generate random DNA for the Initial Generation
* Value Encoding is used for DNA encoding
* DNA = [RED, GREEN, BLUE, ALPHA, X1, Y1, X2, Y2, ...]
* */
randomGenes(){
var bString = [];
for (var i = 0; i < this.chromoSize; i+= this.geneSize){
/**
@ammario
ammario / goth
Created September 2, 2016 16:27
golang test coverage html
#!/bin/bash
go test -coverprofile=coverage.out
go tool cover -html=coverage.out
package main
import (
"fmt"
"io"
"os"
)
var path = "/Users/novalagung/Documents/temp/test.txt"
@sararob
sararob / data-structure.js
Last active April 26, 2022 22:21
Role-based security in Firebase
/*
This example shows how you can use your data structure as a basis for
your Firebase security rules to implement role-based security. We store
each user by their Twitter uid, and use the following simplistic approach
for user roles:
0 - GUEST
10 - USER
20 - MODERATOR
@graydon
graydon / country-bounding-boxes.py
Created April 23, 2014 00:03
country bounding boxes
# extracted from http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip
# under public domain terms
country_bounding_boxes = {
'AF': ('Afghanistan', (60.5284298033, 29.318572496, 75.1580277851, 38.4862816432)),
'AO': ('Angola', (11.6400960629, -17.9306364885, 24.0799052263, -4.43802336998)),
'AL': ('Albania', (19.3044861183, 39.624997667, 21.0200403175, 42.6882473822)),
'AE': ('United Arab Emirates', (51.5795186705, 22.4969475367, 56.3968473651, 26.055464179)),
'AR': ('Argentina', (-73.4154357571, -55.25, -53.628348965, -21.8323104794)),
'AM': ('Armenia', (43.5827458026, 38.7412014837, 46.5057198423, 41.2481285671)),
@manishtpatel
manishtpatel / main.go
Last active October 18, 2023 03:12
GoLang Encrypt string to base64 and vice versa using AES encryption.
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
"fmt"
"io"
)