Skip to content

Instantly share code, notes, and snippets.

View mmun's full-sized avatar

Martin Muñoz mmun

View GitHub Profile
import base64
import subprocess
def encode_powershell_command(command: str) -> str:
return base64.b64encode(command.encode('utf-16-le')).decode('utf-8')
def run_powershell_command(command: str, as_admin: bool = False):
encoded_command = encode_powershell_command(command)
if as_admin:
@mmun
mmun / 18.py
Last active December 19, 2021 16:23
Advent of Code 2018: Day 18
import sys
from copy import deepcopy
def add(x, y):
return reduce([x, y])
def reduce(root):
root = deepcopy(root)
@mmun
mmun / index.js
Created March 16, 2021 20:34
crappy component template colocation polyfill
'use strict';
let path = require('path');
let Funnel = require('broccoli-funnel');
module.exports = {
name: require('./package').name,
preprocessTree(type, tree) {
if (type === 'template') {
/*
This is an example of how you would compose two APIs that use AbortController.
The function `getLocalShops` first gets the user's geolocation coordinates
and then makes a fetch using these coordinates. Both of these operations could be expensive,
so we want to abort them as soon as the outer getLocalShops call is aborted.
*/
@mmun
mmun / components.bar-column.js
Last active March 27, 2018 15:17
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
didRender() {
console.log("bar-column#didRender");
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
init() {
this._super(...arguments);
// Simulate loading data in a route
this.store.push({
data: [
{ type: 'user', id: '1', attributes: { name: 'mmun' } },
@mmun
mmun / adapters.cat.js
Last active April 28, 2017 00:31
New Twiddle
import DS from 'ember-data';
export default DS.JSONAPIAdapter;
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
struct activity {
long s, e, h;
bool operator<(const activity& other) const {
return e < other.e;
}
};
// code snippet
upper_bound(activities.begin(), activities.end(), {0, x, 0}) - a.begin();
@mmun
mmun / controllers.application.js
Last active January 20, 2017 01:31
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
names: ['martin', 'ricardo', 'spencer']
});