Skip to content

Instantly share code, notes, and snippets.

Avatar

Evan Klitzke eklitzke

View GitHub Profile
View rightside.cc
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
* };
View zeroes.cc
class Solution {
public:
void moveZeroes(vector<int>& nums) {
auto end = nums.end();
for (auto pos = std::remove(nums.begin(), nums.end(), 0); pos != end; ++pos) {
*pos = 0;
}
}
};
View gist:c77f7682e4e452cf3491c4a4fa69a6f2
def docme(f):
f.__doc__ = "lol"
return f
@docme
def foo():
pass
# now it's like as if i had put "lol" as the docstring of f
View gist:62c5a1a2f121faebf087780dae845351
_muldi3.o:
0000000000000000 T __multi3
_negdi2.o:
0000000000000000 T __negti2
_lshrdi3.o:
0000000000000000 T __lshrti3
_ashldi3.o:
View lexer.rl
%%{
machine Lexer;
main := |*
'(' => {
CAPTURE_TOKEN_TYPE(Open);
fbreak;
};
View lexer_test.cc
#include <gtest/gtest.h>
#include "lisp/lexer.h"
// Assert that the next token has the given type (with no value).
#define TOKTYPE(t) \
ASSERT_EQ(lexer.NextToken(), lisp::Token(lisp::TokenType::t));
// Assert that the next token has the given type and value.
#define TOKVAL(t, val) \
View wat.c
size_t dirlen = strlen (dir);
char *name = malloc (dirlen + sizeof id_name);
if (unlikely (name == NULL))
break;
memcpy (mempcpy (name, dir, dirlen), id_name, sizeof id_name);
View solution3.cc
#pragma once
#include "solution.h"
using namespace advent;
namespace advent2019 {
class Solution3 : public Solution {
public:
using Point = std::pair<int, int>;
View deltarpm.txt
---------------------
deltarpm suite V3.4
---------------------
A) Programs
makedeltarpm [-V version] [-s seqfile] oldrpm newrpm deltarpm
Extracts the usable files (i.e. no config files) from oldrpm and
View triples.cc
// A sample standard C++20 program that prints
// the first N Pythagorean triples.
#include <iostream>
#include <optional>
#include <ranges> // New header!
using namespace std;
// maybe_view defines a view over zero or one
// objects.
You can’t perform that action at this time.