Skip to content

Instantly share code, notes, and snippets.

View azendal's full-sized avatar

Fernando Trasviña azendal

View GitHub Profile
@azendal
azendal / dynamo.js
Last active February 28, 2024 01:07
//npm install aws-sdk aws-sdk-mock --save-dev
/*
if (process.env.NODE_ENV === 'development') {
require('./mockDynamoDB');
}
*/
/*
4. Running Your Server
@azendal
azendal / chat1
Created February 28, 2023 14:56
exported chats
**message:** If I have a CSV file one record per line how can I get an md5 of the columns, title, ref, description, url
**message:** You can use a programming language like Python to read the CSV file, extract the values of the columns title, ref, description, and url for each record, concatenate them into a single string, and then calculate the MD5 hash of the string.Here is some sample Python code that demonstrates how to do this using the built-in csv and hashlib modules:pythonCopy codeimport csv
import hashlib
filename = "example.csv" # replace with the name of your CSV file
with open(filename, "r") as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
@azendal
azendal / bootstrap.sh
Created January 23, 2023 17:43
bootstrap deploy to a heroku container
#!/bin/bash
# Check if Heroku CLI is installed
if ! command -v heroku &> /dev/null; then
echo "Heroku CLI is not installed, please install it before running this script"
exit 1
fi
# Check if user is logged in
if ! heroku auth:whoami &> /dev/null; then
@azendal
azendal / sample.py
Created January 14, 2023 05:18
test
print("hello world")
@azendal
azendal / sets.js
Created November 16, 2022 17:51
using sets in javascript
// utility fns
var getUid = function(length) {
var i, uid, min, max;
length = length || 32;
uid = '';
min = 0;
max = getUid.codes.length - 1;
for (i = 0; i < length; i++) {
@azendal
azendal / demo.js
Last active November 11, 2022 20:14
filter, map, reduce intro
/*
Applications filter -> Map -> Reduce and how it relates to functional
(Not a functional programming talk)
But a lil functional code
*/
@azendal
azendal / Nitrogen Server
Last active December 10, 2015 14:49 — forked from anonymous/gist:4448997
Small CORS JSON Server
var express = require('express');
var app = express();
app.use(express.bodyParser());
app.get('/:model', function (req, res) {
res.json(data[req.params.model]);
});
app.get('/:model/:id', function (req, res){
var record = data[req.params.model].filter(function (entry) {
@azendal
azendal / Object.defineProperties.js
Created December 4, 2012 14:06 — forked from Mr0grog/Object.defineProperties.js
Object.defineProperties modeled in JS
Object.defineProperties = function(O, Properties) {
// 1. If Type(O) is not Object throw a TypeError exception.
if (typeof(O) !== "object" || O == null) {
throw TypeError("Object.defineProperties called on non-object");
}
// 2. Let props be ToObject(Properties)
var props = Object(Properties); // not *exactly* the same, but similar enough
// 3. Let names be an internal list containing the names of each enumerable own property of props.
@azendal
azendal / example
Created October 10, 2012 01:36
CustomEventSupport
# Example CustomEvent
class Dispatcher
include CustomEventSupport
include BubblingSupport
def set_property(value)
dispatch 'property_change', {:value => value}
end
end
@azendal
azendal / TreeWalker.js
Created June 5, 2012 22:04 — forked from shawndumas/TreeWalker.js
A JavaScript Implementation of TreeWalker
var NodeFilter = {
FILTER_ACCEPT: 1,
FILTER_REJECT: 2,
FILTER_SKIP: 3,
SHOW_ALL: -1,
SHOW_ELEMENT: 1,
SHOW_ATTRIBUTE: 2,
SHOW_TEXT: 4,
SHOW_CDATA_SECTION: 8,
SHOW_ENTITY_REFERENCE: 16,