Skip to content

Instantly share code, notes, and snippets.

@am0d
am0d / extractors.d.ts
Last active October 29, 2024 15:06
Type definitions for Jetbrains IDE data extractors
declare interface IColumn {
name(): string;
columnNumber(): number;
}
declare interface IRow {
data(): IIterable<object>;
rowNumber(): number;
first(): boolean;
last(): boolean;
@am0d
am0d / challenge-2-autobuyer.js
Created June 13, 2022 14:44
Antimatter Dimensions Challenge 2 Autobuyer
var VERBOSE = true;
const log = function () {
if (!VERBOSE) {
return;
}
console.log.apply(null, arguments);
};
class TickChallenge {
function calculate(input) {
let tokens = tokensFromString(input);
let first = numberFromString(tokens[0]);
let second = numberFromString(tokens[2]);
return first + second;
}
function numberFromString(input) {
return parseInt(input, 10);
@am0d
am0d / calculator.cs
Created March 1, 2018 19:47
Interview calculator
// Entry point name must be "Solution"
using System;
using System.Linq;
using System.Collections.Generic;
public static class Solution
{
private static void Main()
{
Console.WriteLine("*** Test Results ***");
@am0d
am0d / Controller.cs
Last active February 27, 2018 15:35
C# Backend architecture
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace Test.Controllers
{
[Route("api/[controller]")]
public class HomeController : AppController
{
public APIResult<List<AppUser>> APIEndpoint([FromQuery] PaginationParams pagination)
cfg: build triple x86_64-unknown-linux-gnu
cfg: host triples x86_64-unknown-linux-gnu
cfg: target triples x86_64-unknown-linux-gnu
cfg: enabling more debugging (CFG_ENABLE_DEBUG)
cfg: host for x86_64-unknown-linux-gnu is x86_64
cfg: os for x86_64-unknown-linux-gnu is unknown-linux-gnu
cfg: using CC=gcc (CFG_CC)
cfg: no pdflatex found, deferring to xelatex
cfg: no xelatex found, deferring to lualatex
cfg: no lualatex found, disabling LaTeX docs
@am0d
am0d / json.rs
Created April 5, 2014 17:47 — forked from madjar/json.rs
/*
* Hi there !
*
* I found that handling Json was quite annoying, so I wrote this
* little lib to help. You can find an example of the usage in the
* tests at the end.
*
* I lacked inspiration on the naming of value() and item(), and got
* lost in the lifetimes, so from_json takes a Json and not a
* JsonLike.

Howto build a rust compiler for the Raspberry Pi on Fedora 18

#sudo yum install git build-essential
#test `uname -m` = x86_64 && sudo apt-get install ia32-libs

git clone https://github.com/raspberrypi/tools.git
export PATH=$PWD/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin:$PATH

git clone http://github.com/mozilla/rust.git

cd rust

@am0d
am0d / stderr
Last active December 23, 2015 00:59
Lifetime error
src/todo_controller.rs:22:8: 22:22 error: cannot infer an appropriate lifetime due to conflicting requirements
src/todo_controller.rs:22 TodoController {
^~~~~~~~~~~~~~
src/todo_controller.rs:21:90: 26:5 note: first, the lifetime cannot outlive the lifetime &'self as defined on the block at 21:90...
src/todo_controller.rs:21 pub fn new(r: &'self Request, rw: &'self mut ResponseWriter) -> TodoController<'self> {
src/todo_controller.rs:22 TodoController {
src/todo_controller.rs:23 request: r,
src/todo_controller.rs:24 response: rw
src/todo_controller.rs:25 }
src/todo_controller.rs:26 }
$ make
rustc -L . -O insertion-sort.rs
insertion-sort.rs:15:28: 15:34 error: use of partially moved value: `result`
insertion-sort.rs:15 let valueToInsert = result[index];
^~~~~~
insertion-sort.rs:15:28: 15:40 note: `(*result)[]` moved here because it has type `T`, which is moved by default (use `copy` to override)
insertion-sort.rs:15 let valueToInsert = result[index];
^~~~~~~~~~~~
insertion-sort.rs:18:45: 18:51 error: use of partially moved value: `result`
insertion-sort.rs:18 while holePos > 0 && valueToInsert < result[holePos - 1] {