Skip to content

Instantly share code, notes, and snippets.

@movich
movich / var_let_const
Last active April 5, 2019 18:20 — forked from mustophatiamiyu/var_let_const
Variable Declarations in JS
/// Outside here is global scope
var global_var = 90;
let global_let = 10;
let ten = 10; // initial value is 10. Operation is called Initialisation
ten = 100; /// the value it stores becomes 100. Operation: Assignment
var twenty = 20; //initial value is 20. Operation is called Initialisation
twenty = 30 // becomes 30, Operation: Assignment
var x = 3;
console.log("Global x: %s", x);
function func(randomize) {
console.log("Global x: %s", x);
if (randomize) {
var x = Math.random(); // (A) scope: whole function
console.log("Local x: %s\n", x);
return x;
}
console.log("Which x?: %s\n", x);
namespace tests
{
template <class T>
void print(T& cont)
{
for(auto& ele: cont)
cout << ele << ' ';
}
template <class T>
@movich
movich / main.cpp
Created October 27, 2017 15:36 — forked from k11m1/main.cpp
#2
#include <SDL2/SDL.h>
#include <iostream>
#include <vector>
#include <thread>
#include <stdlib.h>
#include <time.h>
using namespace std;
void DrawRec(SDL_Renderer* renderer, SDL_Rect r)
@movich
movich / how-to-install-latest-gcc-on-ubuntu-lts.txt
Created October 8, 2017 08:50 — forked from application2000/how-to-install-latest-gcc-on-ubuntu-lts.txt
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 && \