Skip to content

Instantly share code, notes, and snippets.

...
"mounts": [
"type=bind,source=${localEnv:HOME}${localEnv:USERPROFILE}/.gitconfig,target=/home/vscode/.gitconfig,readonly",
"type=bind,source=${localEnv:HOME}${localEnv:USERPROFILE}/.aws,target=/home/vscode/.aws,readonly",
"type=bind,source=${localEnv:HOME}${localEnv:USERPROFILE}/.gnupg,target=/home/vscode/.gnupg,readonly",
"type=bind,source=${localEnv:HOME}${localEnv:USERyyPROFILE}/.ssh,target=/home/vscode/.ssh,readonly"
],
...
## requires a `pip install vobject`
import vobject
import io
import csv
reader = io.open("contacts.vcf", "r", encoding="utf-8")
output_file = open('contacts.csv', mode='w')
writer = csv.writer(output_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
writer.writerow(["username", "name.first", "name.last"])
function getStats(code) {
const flatten = (arr, depth = 1) => arr.reduce((a, v) => a.concat(depth > 1 && Array.isArray(v) ? flatten(v, depth - 1) : v), []);
const words = (str='', pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean);
const stats = {};
const { _id: session, document } = db.sessions.findOne({ code });
const { pages } = db.documents.findOne({ _id: document });
stats.pageCount = pages.length;
const pageObjects = db.pages.find({ _id: { $in: pages } });
@cdinu
cdinu / Todos.sol
Created February 12, 2018 12:11
A simple todo list smart contract in Solidity
pragma solidity ^0.4.0;
contract TodosContract {
address private _owner ;
struct Todo {
string title;
bool completed;
}
@cdinu
cdinu / program.js
Created February 10, 2017 00:58
Measure and display temperature with a BBC Micobit computer
// The number of leds represent how many
// degrees Celsius are above 15C
// run and compile at https://pxt.microbit.org
const getLedArray = (temp: number) => {
const n = Math.max(0, temp - 15);
return[
Math.min(5, n),
Math.max(0, Math.min(5, n - 5)),
@cdinu
cdinu / Dockerfile
Last active October 8, 2016 19:47
LFA dockerfile
FROM learnfwd/lfa
RUN mkdir -p /app
WORKDIR /app
ENV PORT 80
ENV NODE_ENV development
ENTRYPOINT ["bash"]
CMD ["bash"]
@cdinu
cdinu / powow.clj
Created August 12, 2016 09:07
Statistics about the powers of two
(defn powow
[n]
(let [
exp (fn exp [x n] (reduce * (repeat n x)))
pow (str (exp 2N n))
len (count pow)
sum (reduce
(fn
[sum x]
(+ sum (- (int x) (int \0))))
@cdinu
cdinu / a.md
Last active February 18, 2016 11:05
Alina saying good bye
if (self.feeling(you.leaving) === "sad") {
   print("I wish you didn't leave\n");
}

I wish you didn't leave.

~$ _

@cdinu
cdinu / qna.md
Last active February 7, 2016 16:43
Interview prep Learn Forward

De cat timp faceti manuale electronice? O sa va rog sa descrieti foarte pe scurt si pe intelesul unor oameni simpli ce face un manual electronic produs de dumneavoastra. Care e diferenta fata de manualele electronice din sistemul de invatamant romanesc.

Learn Forward face manuale electronice de trei ani.

  • În martie 2013 am lansat în colaboare cu Holcim într-un proiect CSR ceea ce a fost recunoscut de Ministerul Educației drept "Primul Manual Digital". Detalii aici și aici. Această tehnologie nu o mai folosim pentru că deși era extrem de ușor de folosit mergea doar pe iPad-uri și calculatoare Apple. (aceasta este prima iterație)

  • În septembrie 2013 am lansat în colaborare cu Samsung, sistemul de management al învățării (Learning Management System) destinat claselor lor digitale din România și Bulgaria. În urma discuțiilor cu profesorilor am aj

@cdinu
cdinu / getxypercent.js
Created September 25, 2015 13:42
Get XY coordinates as percentages
// 1. Load an image in a new tab
// 2. Open JS console. Leave it open
// 3. Paste this
var s = document.createElement('script');
s.setAttribute('src','https://code.jquery.com/jquery-2.1.4.min.js');
document.head.appendChild(s);
// 4. Then paste this
var oldx = 0, oldy = 0;