Skip to content

Instantly share code, notes, and snippets.

View rdemorais's full-sized avatar
🏠
Working from home

Rafael de Morais rdemorais

🏠
Working from home
View GitHub Profile
@DarrylD
DarrylD / directive.js
Created February 14, 2015 22:02
ionic slide box dynamic height - fixes the issue where the slide boxes aren't taking up the full height of the device
app.directive('dynamicHeight', function() {
return {
require: ['^ionSlideBox'],
link: function(scope, elem, attrs, slider) {
scope.$watch(function() {
return slider[0].__slider.selected();
}, function(val) {
//getting the heigh of the container that has the height of the viewport
var newHeight = window.getComputedStyle(elem.parent()[0], null).getPropertyValue("height");
if (newHeight) {
@jlln
jlln / separator.py
Last active November 9, 2023 19:59
Efficiently split Pandas Dataframe cells containing lists into multiple rows, duplicating the other column's values.
def splitDataFrameList(df,target_column,separator):
''' df = dataframe to split,
target_column = the column containing the values to split
separator = the symbol used to perform the split
returns: a dataframe with each entry for the target column separated, with each element moved into a new row.
The values in the other columns are duplicated across the newly divided rows.
'''
def splitListToRows(row,row_accumulator,target_column,separator):
split_row = row[target_column].split(separator)
@joinAero
joinAero / BluetoothCallback.java
Last active October 7, 2021 15:42
Android - The bluetooth listener and profile proxy.
package cc.cubone.turbo.core.bluetooth;
/**
* Interface definition for a callback to be invoked when bluetooth state changed.
*/
public interface BluetoothCallback {
/**
* Called when the bluetooth is off.
*/
@cagataycali
cagataycali / babelInterpreter.sh
Created July 8, 2016 16:28
Start pm2 process with babel-node interpreter
pm2 start app.js --interpreter ./node_modules/.bin/babel-node
@thomasdarimont
thomasdarimont / KeycloakAdminClientExample.java
Last active February 1, 2025 18:22
Using Keycloak Admin Client to create user with roles (Realm and Client level)
package demo.plain;
import org.keycloak.OAuth2Constants;
import org.keycloak.admin.client.CreatedResponseUtil;
import org.keycloak.admin.client.Keycloak;
import org.keycloak.admin.client.KeycloakBuilder;
import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.admin.client.resource.UserResource;
import org.keycloak.admin.client.resource.UsersResource;
import org.keycloak.representations.idm.ClientRepresentation;
@xtornasol512
xtornasol512 / README.md
Created July 15, 2017 04:30 — forked from celisflen-bers/README.md
Python script to convert DBF database file to CSV
@justinfx
justinfx / py3_asyncore_server.py
Created October 24, 2017 11:15
python3 asyncore + threading socket server
import asyncore
import socket
import threading
class ChatServer(asyncore.dispatcher):
def __init__(self, host, port):
asyncore.dispatcher.__init__(self)
@egeulgen
egeulgen / boto3_progress_bar.py
Last active October 28, 2024 12:22
To display progress bar and percentage when downloading with boto3
class ProgressPercentage(object):
''' Progress Class
Class for calculating and displaying download progress
'''
def __init__(self, client, bucket, filename):
''' Initialize
initialize with: file name, file size and lock.
Set seen_so_far to 0. Set progress bar length
'''
self._filename = filename
@elviswolcott
elviswolcott / delete-layer.sh
Created January 26, 2020 08:05
Delete all Lambda layer versions across all regions
layer=$1
get_regions () {
echo $(aws ssm get-parameters-by-path --region "us-east-1" --path /aws/service/global-infrastructure/services/lambda/regions --query 'Parameters[].Value' --output text | tr '[:blank:]' '\n' | grep -v -e ^cn- -e ^us-gov- | sort -r)
}
regions=$(get_regions)
get_versions () {
echo $(aws lambda list-layer-versions --layer-name "$layer" --region "$region" --output text --query LayerVersions[].Version | tr '[:blank:]' '\n')
}
@MattLowrieDS
MattLowrieDS / compute_class_weight
Created January 6, 2021 03:07
Example using sklearn compute_class_weight()
from sklearn.utils.class_weight import compute_class_weight
pass_results = plays_df.loc[plays_df['passResult'].isin(category_lookup.keys()), 'passResult']
all_labels = pass_results.apply(lambda lbl: category_lookup[lbl])
# Create class weights to counter-balance classification during training
y = np.stack(all_labels).argmax(axis=1)
classes = np.unique(y)
weights = compute_class_weight('balanced', classes=classes, y=y)
class_weights = {k: v for k, v in zip(classes, weights)}
print('Class weights:', class_weights)