Skip to content

Instantly share code, notes, and snippets.

Dùng yield để return về 1 mảng dữ liệu lớn tránh tràn bộ nhớ
function gen_one_to_three() {
for($i; $<3; $i++) {
yield $i;
}
}
----------------------------------------------------------------------
1920x900
1280x600
980x1280
800x1280
768x1024
360x640
320x480
function getRealIP()
{
if (isset($_SERVER['HTTP_CLIENT_IP'])) {
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
} else if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else if (isset($_SERVER['HTTP_X_FORWARDED'])) {
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
} else if (isset($_SERVER['HTTP_FORWARDED_FOR'])) {
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
Go to Settings, Update & security, Windows Update, Advanced options,
Choose how updates are delivered, Updates from more than one place.
Turn the switch OFF.
Add user to root group
```bash
$>sudo usermod -aG sudo <username>
```
SWAP
$>sudo swapon --show
$>free -h
$>df -h
class Toppings {
constructor(toppings) {
this.toppings = Array.isArray(toppings) ? toppings : [];
}
outputList() {
this.toppings.forEach((topping, i) => console.log(topping, i + '/' + this.toppings.length))
}
}
var ctrl = new Toppings(['cheese', 'lettuce']);
@vinacms
vinacms / stream_to_youtube.sh
Created November 23, 2016 17:50 — forked from olasd/stream_to_youtube.sh
Stream video to youtube via ffmpeg
#! /bin/bash
#
# Diffusion youtube avec ffmpeg
# Configurer youtube avec une résolution 720p. La vidéo n'est pas scalée.
VBR="2500k" # Bitrate de la vidéo en sortie
FPS="30" # FPS de la vidéo en sortie
QUAL="medium" # Preset de qualité FFMPEG
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" # URL de base RTMP youtube
function closePrint () {
document.body.removeChild(this.__container__);
}
function setPrint () {
this.contentWindow.__container__ = this;
this.contentWindow.onbeforeunload = closePrint;
this.contentWindow.onafterprint = closePrint;
this.contentWindow.focus(); // Required for IE
this.contentWindow.print();
@vinacms
vinacms / ansii code
Last active November 12, 2016 08:14
&raquo; »
&laquo; «
&ordm; º
&aelig; æ
&permil; ‰
@vinacms
vinacms / Dockerfile
Created November 5, 2016 07:24 — forked from Lewiscowles1986/Dockerfile
PhalconPHP 2.1 Vagrant & Docker for PHP7 build...
FROM ubuntu:16.04
RUN apt-get -y update && apt-get install -y php7.0-fpm php7.0-cli php7.0-curl php7.0-gd php7.0-intl php7.0-zip php7.0-pgsql build-essential git gcc make re2c libpcre3-dev php7.0-dev curl
RUN curl -sS http://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer
RUN composer global require "phalcon/zephir:dev-master"
RUN mkdir -p /opt/www