This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <tuple> | |
#include <vector> | |
#include <fstream> | |
#include <algorithm> | |
#include <functional> | |
using namespace std; | |
void print(const vector<int>& nums, ostream& fout) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local combo = require "combo" | |
function print_table(T) | |
local str="" | |
for i,v in ipairs(T) do | |
str = str .. string.format("%d,",v) | |
end | |
print(str) | |
end | |
for p in combo.combo_gen({1,2,3,4,5,6,7}, 1) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Modified version of extend.c in luajit source code | |
* GCC compile command is as follows | |
* g++ -I $HOME/.local/include/ -fPIC -shared -o mysin.so extend.cc | |
* Notice that it is NOT linked with the lua library | |
* because in Linux, executables can export functions and | |
* linking is done on load | |
*/ | |
#include <math.h> | |
#include <luajit/lua.hpp> | |
static |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Lua C API | |
#include <luajit/lua.hpp> | |
// C++ input/output streams | |
#include <iostream> | |
// MyObject as C++ class | |
class MyObject{ | |
private: | |
double x; | |
public: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const lines = [ | |
[0, 1, 2], | |
[3, 4, 5], | |
[6, 7, 8], | |
[0, 3, 6], | |
[1, 4, 7], | |
[2, 5, 8], | |
[0, 4, 8], | |
[2, 4, 6], | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/openresty/luajit/bin/luajit | |
--this is the code as described in | |
-- Chapter 26, "Programming Lua" by Roberto Ierusalimschy | |
--except for the function dispatch2 which is a replacement | |
--for dispatch. It uses the return value of select to access | |
--only the ready sockets. There is a small change to download to save | |
--the file as well | |
local socket = require "socket" | |
local function receive (connection) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
For example if the input is "charachter" the output shout be "carac" | |
*/ | |
#include <iostream> | |
#include <string> | |
class CostArray{ | |
int *cost; | |
int width; | |
public: | |
CostArray(int m, int n):width(n){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{beamer} | |
\begin{document} | |
\title{ABC of Vim} | |
\author{Joe Mariadassou} | |
\date{\today} | |
\frame{\titlepage} | |
\frame{\frametitle{Table of contents}\tableofcontents} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let lower_bound cmp arr x = | |
let rec aux lo hi = | |
if lo = hi then lo | |
else let mid = lo + (hi-lo)/2 in | |
if cmp arr.(mid) x < 0 | |
then aux (mid + 1) hi | |
else aux lo (mid) | |
in aux 0 (Array.length arr) | |
let upper_bound cmp arr x = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <vector> | |
using std::wstring; | |
const std::vector< wstring> first20 { | |
L"zero", L"one", L"two", L"three", L"four", L"five", L"six", L"seven", L"eight", L"nine", L"ten", | |
L"eleven", L"twelve", L"thirteen", L"fourteen", L"fifteen", L"sixteen", L"seventeen", L"eighteen", L"nineteen" }; | |
const std::vector< wstring> tees{ L"zero", L"ten", L"twenty",L"thirty", L"forty", L"fifty", L"sixty", L"seventy", L"eighty", L"ninety" }; | |
wstring int_to_str(unsigned int n) | |
{ | |
if (n < 20) |
NewerOlder