Skip to content

Instantly share code, notes, and snippets.

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

Roberto Oliveros roboli

🏠
Working from home
View GitHub Profile
@roboli
roboli / object-keys.ts
Created April 9, 2024 11:33
Using Object.keys(obj) in Typescript
function objectKeys<T>(obj: T): (keyof T)[] {
return Object.keys(obj) as (keyof T)[];
}
// ...
// Avoid the array of strings coming from Object.keys in TS source https://twitter.com/mattpocockuk/status/1502264005251018754?ref_src=twsrc%5Etfw%7Ctwcamp%5Etweetembed%7Ctwterm%5E1502264005251018754%7Ctwgr%5E1d1ec82885093024cd07b1d7a4a1d21f4e095a76%7Ctwcon%5Es1_c10&ref_url=https%3A%2F%2Fwww.mattstobbs.com%2Fobject-keys-typescript%2F
// objectKeys(myObj).find( ... );
@roboli
roboli / mixins.dart
Created April 6, 2024 19:11
Dart: Access Mixins and Class instance variables
mixin Address on Person {
late final String address;
say() {
print("Name: $name, Address: $address");
}
}
class Person {
late final String name;
#!/bin/bash
function print-help() {
echo "Clone database, use locally only."
echo ""
echo " mysql_clone username password old_db new_db"
echo ""
echo "Options:"
echo ""
echo " username: Database username from where you want to copy database"
function loadUtils(opts) {
opts = opts || {};
var $ = opts.$;
var Promise = opts.Promise;
var dbaClient = opts.dbaClient;
var tryAgainUri = opts.tryAgainUri;
var additionalQuestionsUri = opts.additionalQuestionsUri;
setupFormEvents();
function getUrlVars(url) {
var vars = [], hash;
var hashes = url.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
function loadUtils(opts) {
opts = opts || {};
var $ = opts.$;
var Promise = opts.Promise;
var dbaClient = opts.dbaClient;
var tryAgainUri = opts.tryAgainUri;
function redirectToSign(leadId) {
function loadUtils(opts) {
opts = opts || {};
var $ = opts.$;
var Promise = opts.Promise;
var dbaClient = opts.dbaClient;
var tryAgainUri = opts.tryAgainUri;
function redirectToSign(leadId) {
var DBA_CLIO_URI = 'https://6d821675.ngrok.io/';
var LEAD_GROUP = 51940;
function getUrlVars(url) {
var vars = [], hash;
var hashes = url.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
@roboli
roboli / flatten.js
Last active November 16, 2017 14:23
const flatten = (array) => {
// Concat nested arrays recursively
const f = (arr, acc) => {
if(arr.length > 0) {
const first = arr[0];
if(Array.isArray(first)) {
// Item is an array, start new call
acc = acc.concat(f(first, []));
} else {
var expect = require('chai').expect,
parse = require('../parser');
describe('Replace Values', function() {
it('should replace values in string with object properties values', function() {
var obj = {
'ab49fd20': {
key_1: 'some data'
},
'9822df87': {