Skip to content

Instantly share code, notes, and snippets.

View thekvs's full-sized avatar

Konstantin Sorokin thekvs

View GitHub Profile
@thekvs
thekvs / gist:7d2f29404d28c9c742bf3c825e1990f5
Last active March 4, 2021 11:28
Get latest release URL from GitHub using jq
curl --silent "https://api.github.com/repos/goreleaser/goreleaser/releases/latest" | jq -r '.assets[] | select (.name|test("amd64.deb")) | .browser_download_url'
curl --silent "https://api.github.com/repos/goreleaser/goreleaser/releases/latest" | jq -r '.assets[] | select (.name|test("Linux_x86_64.tar.gz")) | .browser_download_url'
@thekvs
thekvs / expand-compile-commands-json.py
Last active June 13, 2019 17:34
flatten @path/to/file.rsp entries in compile_commands.json file so that it can be used by clangd
import argparse
import json
import copy
import sys
import os.path
import traceback
def parse_args():
parser = argparse.ArgumentParser(
package main
import (
"net/http"
"runtime"
)
@thekvs
thekvs / remove-all-docker-images.sh
Created March 1, 2018 15:40
Remove all docker images
#!/bin/sh
# clear containers
docker rm -f $(docker ps -a -q)
# clear images
docker rmi -f $(docker images -a -q)
# clear volumes:
docker volume rm $(docker volume ls -q)
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"os/signal"
"runtime"
#include <fstream>
#include <string>
int
main()
{
std::string file = "/tmp/a_file.txt";
std::ofstream dst(file, std::ios::trunc);
dst << "Hello, world!" << std::endl;
// g++ -Wall -Wextra -std=c++11 fakeprg.cpp -o /tmp/fakeprg
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <unistd.h>
#include <signal.h>
@thekvs
thekvs / gstreamer-build.sh
Created December 28, 2016 16:18 — forked from sphaero/gstreamer-build.sh
Install & build gstreamer from git
#!/bin/bash --debugger
set -e
BRANCH="master"
if grep -q BCM2708 /proc/cpuinfo; then
echo "RPI BUILD!"
RPI="1"
fi
[ -n "$1" ] && BRANCH=$1
@thekvs
thekvs / t.py
Created November 15, 2015 12:00
select and change values in the data frame using frequency criteria
import pandas as pd
df = pd.DataFrame({'a': [1, 2, 3, 3, 4, 1, 7, 8, 9], 'b': [1, 1, 1, 1, 4, 4, 2, 3, 1]})
print(df)
print("========")
cidx = df.b.value_counts() <= 1
df.loc[df.b.isin(cidx.index[cidx]), 'b'] = 9999
print(df)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.