Skip to content

Instantly share code, notes, and snippets.

View vladimirgamalyan's full-sized avatar
👽
work for mood

Vladimir Gamalyan vladimirgamalyan

👽
work for mood
  • Yerevan, Armenia
View GitHub Profile
@jannismain
jannismain / CompactJSONEncoder.py
Last active July 4, 2024 14:59
A JSON Encoder in Python, that puts small lists on single lines.
#!/usr/bin/env python3
from __future__ import annotations
import json
class CompactJSONEncoder(json.JSONEncoder):
"""A JSON Encoder that puts small containers on single lines."""
CONTAINER_TYPES = (list, tuple, dict)
@arhadthedev
arhadthedev / We're more aggressively enforcing self-moderation in chat.md
Last active September 14, 2018 08:46
Мы переходим к значительно более принудительному самомодерированию в чате

Данный вопрос является переводом публикации Тима Поста «We're more aggressively enforcing self-moderation in chat».


Хоть написание текста ниже и пришлось на период нашей озабоченности тем, что мы не до конца справляемся с превращением Stack Overflow в место, дружелюбное к каждому, есть ещё нечто, тяготеющее над нами уже долгое время и затрагивающее каждый сайт, связанный с системой чатов, то есть все.

Иногда возникают проблемы, зреющие месяцами и даже годами; и когда они вскрываются, исход получается крайне неприятным. Без преувеличения скажу, что я крайне горд за те девяносто семь процентов от всех чат-комнат, которые держатся на уровне мест, наиболее подходящих для спокойного ведения разговоров по делу. Они прекрасно доказывают, что ответственные люди способны раскрыть лучшее друг в друге даже в условиях размытых формулировок правил *[частичный перев

@SaschaWillems
SaschaWillems / activity.java
Last active November 1, 2023 06:54
Displaying a native android alert dialog from C++ using JNI
package com.yourpackage.appname;
import java.util.concurrent.Semaphore;
public class MyActivity extends NativeActivity {
static {
// Load native library
System.loadLibrary("native-lib");
}
@application2000
application2000 / how-to-install-latest-gcc-on-ubuntu-lts.txt
Last active May 23, 2024 07:53
How to install latest gcc on Ubuntu LTS (12.04, 14.04, 16.04)
These commands are based on a askubuntu answer http://askubuntu.com/a/581497
To install gcc-6 (gcc-6.1.1), I had to do more stuff as shown below.
USE THOSE COMMANDS AT YOUR OWN RISK. I SHALL NOT BE RESPONSIBLE FOR ANYTHING.
ABSOLUTELY NO WARRANTY.
If you are still reading let's carry on with the code.
sudo apt-get update && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
@carlos-jenkins
carlos-jenkins / multihooks.py
Last active August 10, 2023 22:12
Delegating script for multiple git hooks
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2015-2017 Carlos Jenkins <carlos@jenkins.co.cr>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@vladon
vladon / boost_asio_streambuf_to_string.cpp
Last active May 27, 2023 06:45
Returns `boost::asio::streambuf` contents represented as `std::string`
std::string buffer_to_string(const boost::asio::streambuf &buffer)
{
using boost::asio::buffers_begin;
auto bufs = buffer.data();
std::string result(buffers_begin(bufs), buffers_begin(bufs) + buffer.size());
return result;
}
@Fire-
Fire- / installDante.sh
Created October 3, 2014 19:53
Basic Dante Socks5 Server Setup and Configuration
# Basic Dante Socks5 Setup, Debian
apt-get update
apt-get install make gcc
cd /usr/src
# get newest from http://www.inet.no/dante/download.html
wget http://www.inet.no/dante/files/dante-1.4.1.tar.gz
@ksimek
ksimek / program_options_boilerplate.cpp
Last active December 28, 2023 05:12
Boilerplate code for a C++ program using boost program options. Usage string is automatically generated from positional arguments.
#include <boost/program_options.hpp>
#include <sstream>
#include <fstream>
#include <iterator>
#include <algorithm>
namespace po = boost::program_options;
class Options
{
@randomphrase
randomphrase / cmdoptions.cpp
Last active May 25, 2024 08:26
Demonstration of how to do subcommand option processing with boost program_options
#define BOOST_TEST_MODULE subcommand options
#include <boost/test/unit_test.hpp>
#include <boost/program_options.hpp>
#include <boost/variant/variant.hpp>
#include <boost/variant/get.hpp>
struct GenericOptions {
bool debug_;
};
@acidleaf
acidleaf / vec2.h
Last active June 28, 2024 07:40
C++ 2D Vector
/*
Copyright (c) 2020 Chan Jer Shyan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: