Skip to content

Instantly share code, notes, and snippets.

View sumeet's full-sized avatar

Sumeet Agarwal sumeet

  • San Francisco, CA
View GitHub Profile
use std::collections::HashMap;
use std::fs::read_to_string;
fn main() {
let filestr = read_to_string("example.csv").unwrap();
let mut lines = filestr.lines();
let header_row = lines.next().unwrap();
let field_names : Vec<_> = header_row.split(",").collect();
let objects : Vec<HashMap<_, _>> = lines.map(|line| {

Command line adder

Adds together all numbers separated by newlines from input. If an empty line is given, doesn't add anything to the total sum (i.e., it adds 0).

Terminate the program by either sending EOF (Ctrl-D), or with the keyword END. Upon termination, the program will print out the whole sum.

Example:

$ cargo run
diff '--color=auto' -U1000 -r -u plasma-desktop-5.24.5/applets/pager/plugin/windowmodel.cpp plasma-desktop-5.24.5-modded/applets/pager/plugin/windowmodel.cpp
--- plasma-desktop-5.24.5/applets/pager/plugin/windowmodel.cpp 2022-05-03 03:31:25.000000000 -0700
+++ plasma-desktop-5.24.5-modded/applets/pager/plugin/windowmodel.cpp 2022-06-20 10:37:59.906814525 -0700
@@ -1,138 +1,150 @@
/*
SPDX-FileCopyrightText: 2016 Eike Hein <hein.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "windowmodel.h"
#include <stdio.h>
#include <algorithm>
// print regular triangle
// for n = 5
// X
// XX
// XXX
// XXXX
// XXXXX
#include <stdio.h>
// we're going for something like this
//
// * // row #0 // 1 star
// * * * // row #1 // 3 stars
// * * * * * // row #2 // 5 stars
// * * * * * * * // row #3 // 7 stars
// * * * * * * * * * // row #4 // 9 stars
#include <stdio.h>
// [a b c d]
// [a a a b c]
void merge(int* nums1, int nums1Size, int m, int* nums2, int nums2Size, int n){
static int nums1_copy[200];
memcpy(nums1_copy, nums1, m * sizeof(int));
int input_cursor = 0;
@sumeet
sumeet / playground.rs
Last active March 31, 2022 21:39 — forked from rust-play/playground.rs
Code shared from the Rust Playground
const SAMPLE_FLAT_LIST: &str = "(a b c d e f)";
const SAMPLE_NESTED_LIST: &str = "(a b c (d (e word-word) f))";
const SAMPLE_WORD: &str = "sample-word";
#[derive(Debug)]
enum Expr {
List(Vec<Expr>),
Word(String),
}
@sumeet
sumeet / input.js
Created October 14, 2021 01:43
exapunks
smt {
open(300) {
username = fread()
}
link 800
open(199) {
while (username != fread()) {
file.seek(2)
}
fseek(1)
# originally from https://inventwithpython.com/pygameHelloWorld.py
import pygame, sys
from pygame.locals import *
# set up pygame
pygame.init()
# set up the window
windowSurface = pygame.display.set_mode((500, 400), 0, 32)
pygame.display.set_caption('Hello world!')
@sumeet
sumeet / hello_sdl2.c
Last active June 30, 2021 21:14 — forked from fschr/main.cpp
SDL2 Hello World
// SDL2 Hello, World!
// This should display a white screen for 2 seconds
// compile with: gcc -o hello_sdl2 -lSDL2 hello_sdl2.c
// run with: ./hello_sdl2
#include <SDL2/SDL.h>
#include <stdio.h>
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480