Skip to content

Instantly share code, notes, and snippets.

View Zikoel's full-sized avatar

Elia Mazzuoli Zikoel

  • Italia
View GitHub Profile
@Zikoel
Zikoel / main.ts
Created January 11, 2022 14:16
Creation of a Budget, Campaign, GroupAd and AdGroupAd resources atomically with opteo library
import { enums, GoogleAdsApi, MutateOperation, toMicros } from 'google-ads-api'
import { loadGadsCredentialFromFile } from '../gadsCredentialsValidator'
import { inspect } from 'util'
const cred = {
client_id: '',
client_secret: '',
developer_token: '',
refresh_token: '',
login_customer_id: '',
@Zikoel
Zikoel / index.js
Created January 26, 2020 11:25
Array flatten js function
// Of course we can use something like this [lodash flattenDeep](https://lodash.com/docs/4.17.15#flattenDeep)
// but here we want our solution
const nestedArray = [[1,2,[3]],4]
const moreNestedArray = [1,2,[[[5, 6, [8, [9], [10]]]]]]
const flat = array => {
return array.reduce( (acc, cur) =>
typeof cur === 'number'
@Zikoel
Zikoel / main.cpp
Created July 17, 2018 09:21
Iterating over a parameter pack
#include <assert.h>
#include <type_traits>
template<typename T, typename... Others>
struct splitter{
using Head = T;
template <template <typename...> typename U> using Tail = U<Others...>;
};
int main() {
@Zikoel
Zikoel / multi_th_scandir.cpp
Created January 23, 2018 10:54
Code for evidence that errno was thread safe
#include <string>
#include <iostream>
#include <thread>
#include <vector>
#include <dirent.h>
#include <cerrno>
struct ScanResult {
int returnCode;
int errnoCode;
@Zikoel
Zikoel / main.cpp
Created November 17, 2017 13:37
Little exple of template specializations
#include <iostream>
struct Worker
{
template<typename TProcedure>
void execute(TProcedure p);
};
struct A
{
@Zikoel
Zikoel / main.cpp
Created September 7, 2017 09:49
A way for iterate over complex tuple elements
#include <tuple>
#include <vector>
#include <iostream>
#include <utility>
template <typename ...Types>
struct A
{
std::tuple<std::vector<Types>...> t;
};
@Zikoel
Zikoel / main.cpp
Created August 23, 2017 16:11
A way for retrieve type from complex object inside a tuple.
#include <iostream>
#include <tuple>
#include <unordered_map>
template<typename ...TKeyTypes>
struct A {
std::tuple<std::unordered_map<TKeyTypes, size_t>...> tupled_maps;
};
int main()
@Zikoel
Zikoel / index.js
Created April 16, 2017 08:38
Bookshelf table related example
'use strict';
const config = require('./knexfile')['development'];
const knex = require('knex')(config);
const bookshelf = require('bookshelf')(knex);
let User = bookshelf.Model.extend({
tableName: 'users',
messages: function() {
return this.hasMany(Messages);
@Zikoel
Zikoel / MainApp.java
Created June 26, 2016 14:31
Java generics
public class A {
public A() {
MainApp.decorateMyClass(this);
}
}
public class B {
public B() {
MainApp.decorateMyClass(this);
}