Skip to content

Instantly share code, notes, and snippets.

Avatar

Krzysztof Kowalczyk kjk

View GitHub Profile
View main.go
// :collection Essential Go
package main
import (
"fmt"
)
// :show start
// addCheckOverflow adds two int16 numbers and additionally
// returns true if the result overflowed
View main.js
const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
let newArr = arr.slice(0, 2);
console.log("slice(0,2) :", newArr)
newArr = arr.slice(8);
console.log("slice(8) :", newArr)
newArr = arr.slice(5, -1);
console.log("slice(5, -1):", newArr)
View main.cc
#include <iostream>
int main()
{
int x = 1;
if (x > 0) {
std::cout << "x (" << x << ") is greater than zero\n";
}
}
View main.go
package main
import (
"fmt"
"log"
"os"
)
func main() {
// :show start
View read file into lines.go
// :collection Essential Go
package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"os"
)
@kjk
kjk / create_zip_file.go
Last active Jun 29, 2020
Create ZIP file in Go (made with https://codeeval.dev)
View create_zip_file.go
package main
import (
"archive/zip"
"fmt"
"io"
"log"
"os"
"path/filepath"
)
@kjk
kjk / factorial.cc
Created Jun 29, 2020
fancy factorial with templates (made with https://codeeval.dev)
View factorial.cc
#include <iostream>
#include <utility>
template <class T, T N, class I = std::make_integer_sequence<T, N>>
struct factorial;
template <class T, T N, T... Is>
struct factorial<T,N,std::index_sequence<T, Is...>> {
static constexpr T value = (static_cast<T>(1) * ... * (Is + 1));
};
View faster_binary_tree.go
package main
import (
"flag"
"fmt"
"log"
"os"
"runtime/debug"
"runtime/pprof"
"strconv"
@kjk
kjk / github graphql.txt
Created Jun 18, 2020
github graphql examples (made with https://codeeval.dev)
View github graphql.txt
{
viewer {
gists(first: 10) {
nodes {
id
isPublic
isFork
name
pushedAt
createdAt
You can’t perform that action at this time.