Skip to content

Instantly share code, notes, and snippets.

View kjk's full-sized avatar

Krzysztof Kowalczyk kjk

View GitHub Profile
@kjk
kjk / github graphql.txt
Created June 18, 2020 02:03
github graphql examples (made with https://codeeval.dev)
{
viewer {
gists(first: 10) {
nodes {
id
isPublic
isFork
name
pushedAt
createdAt
// :collection Essential Go
package main
import (
"fmt"
"sync"
)
// :show start
var wg sync.WaitGroup
// :glot
package main
import "fmt"
// :show start
func filterEvenValuesInPlace(a []int) []int {
// create a zero-length slice with the same underlying array
res := a[:0]
package main
import "fmt"
// :show start
func filterEvenValues(a []int) []int {
var res []int
for _, el := range a {
if el%2 == 0 {
continue
#include <iostream>
constexpr long long factorial(int n)
{
long long result = 1;
for (int i = 1; i <= n; ++i) {
result *= i;
}
return result;
}
#include <iostream>
constexpr long long factorial(long long n)
{
if (n == 0)
return 1;
else
return n * factorial(n - 1);
}
#include <iostream>
constexpr long long factorial(long long n)
{
return (n == 0) ? 1 : n * factorial(n - 1);
}
int main()
{
char test[factorial(3)];
#include <iostream>
#include <type_traits>
template<long long n>
struct factorial :
std::integral_constant<long long, n * factorial<n - 1>::value> {};
template<>
struct factorial<0> :
std::integral_constant<long long, 1> {};
#include <iostream>
template<unsigned int n>
struct factorial
{
enum
{
value = n * factorial<n - 1>::value
};
};
@kjk
kjk / main.go
Created November 6, 2019 01:29
Essential Go: basics of structs (made with https://codeeval.dev)
// :glot, no output
package main
// :show start
type MyStruct struct {
IntVal int
StringVal string
unexportedIntVal int
}