Skip to content

Instantly share code, notes, and snippets.

View radxene's full-sized avatar

Radu Ene radxene

  • Moldova, Chisinau
View GitHub Profile
@radxene
radxene / read_lines_from_file.go
Created October 10, 2017 09:13
Golang - Read Lines From File
package main
import (
"bufio"
"fmt"
"os"
)
func ReadFileLines(filePath string) []string {
f, err := os.Open(filePath)
@radxene
radxene / read_lines_from_string.go
Created October 10, 2017 09:10
Golang - Read Lines From String
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
func ReadStringLines(s string) []string {
@radxene
radxene / send-bigfile.php
Last active August 25, 2017 21:37
Send big file to server
<?php
$filename = !empty($_GET["filename"]) ? $_GET["filename"] : null;
if ($filename) {
$chunk = file_get_contents("php://input");
file_put_contents($filename, $chunk, FILE_APPEND);
}
?>
@radxene
radxene / color_output.c
Created August 13, 2017 11:23
Colored output in C
/**
* For compiling program run:
* gcc -std=c99 color_output.c -o color_output.run
*/
#include <stdio.h>
#define ANSI_RESET_ALL "\x1b[0m"
#define ANSI_COLOR_BLACK "\x1b[30m"
#define ANSI_COLOR_RED "\x1b[31m"
@radxene
radxene / window_list.c
Created August 13, 2017 10:46
Delete or Install gnome-shell-extension-window-list in Centos 7
/**
* For compiling program run:
* gcc -std=c99 window_list.c -o window_list.run
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ANSI_COLOR_GREEN "\x1b[32m"
#define ANSI_COLOR_RESET "\x1b[0m"
## Add in Gemfile
group :development, :test do
# ...
gem 'rspec-rails'
gem 'factory_girl_rails'
end
group :test do
gem 'shoulda-matchers', '~> 3.0'
end
PROJECT=start
rbenv gemset init $PROJECT
rbenv gemset active
gem install rails
rails new $PROJECT -d postgresql
# config/database.yml
@radxene
radxene / svg_form_img.js
Created October 30, 2016 09:39
Insert inline svg in document from images src
window.addEventListener('load', function () {
'use strict';
var images = document.querySelectorAll("img[src$='.svg'");
var len = images.length;
for (var i = 0; i < len; i++) {
var img = images[i];
svgFromIMG(img);
}
@radxene
radxene / install-gcc.sh
Created September 30, 2016 07:35
Build GCC 4.9.2 for C/C++ on CentOS 7
sudo yum install libmpc-devel mpfr-devel gmp-devel
cd ~/Downloads
curl ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-4.9.2/gcc-4.9.2.tar.bz2 -O
tar xvfj gcc-4.9.2.tar.bz2
cd gcc-4.9.2
./configure --disable-multilib --enable-languages=c,c++
make -j 4
sudo make install
@radxene
radxene / default.php
Last active June 14, 2016 06:59
Library PHP
<?php
function __autoload($class)
{
$parts = explode('\\', $class);
require end($parts) . '.php';
}