Skip to content

Instantly share code, notes, and snippets.

View gentoid's full-sized avatar
😃

Viktor Lazarev gentoid

😃
View GitHub Profile
body {
font-size: 5vw;
}
@media (max-width: 700px) {
body {
font-size: 35px;
}
}
@media (min-width: 3000px) {
body {
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
]
}
@gentoid
gentoid / main.rs
Last active July 29, 2018 18:25
Human readable time diff
mod time_diff;
use time_diff::TimeDiff;
fn main() {
let td = TimeDiff::new(1234123);
let td2 = TimeDiff::new(1233);
println!("First diff is {}", td);
println!("Second diff is {}", td2);
println!("Sum of that diffs is {}", td + td2);
  • Dynamic Dispatch
  • Dynamic Method
  • Ghost Methods
  • Dynamic Proxies
  • Blank Slate
  • Kernel Method
  • Flattening the Scope (aka Nested Lexical Scopes)
  • Context Probe
  • Class Eval (not really a 'spell' more just a demonstration of its usage)
  • Class Macros
@gentoid
gentoid / destructuring.md
Created August 23, 2016 12:11 — forked from yang-wei/destructuring.md
Elm Destructuring (or Pattern Matching) cheatsheet

Destructuring(or pattern matching) is a way used to extract data from a data structure(tuple, list, record) that mirros the construction. Compare to other languages, Elm support much less destructuring but let's see what it got !

Tuple

myTuple = ("A", "B", "C")
myNestedTuple = ("A", "B", "C", ("X", "Y", "Z"))

let
  (a,b,c) = myTuple
@gentoid
gentoid / callback.php
Created January 22, 2013 11:56
json_encode. Workaround for PHP < 5.1.6
/**
* Workaround for PHP < 5.1.6
*/
if (!function_exists('json_encode')) {
function json_encode($data) {
switch ($type = gettype($data)) {
case 'NULL':
return 'null';
case 'boolean':
return ($data ? 'true' : 'false');
@gentoid
gentoid / ajax_setup.js
Created June 20, 2016 17:56 — forked from alanhamlett/ajax_setup.js
Sets the X-CSRFToken header for every jQuery ajax non-GET request to make CSRF protection easy. This fixes the example from Django docs here: https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (settings.type == 'POST' || settings.type == 'PUT' || settings.type == 'DELETE') {
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHYAMnK0x4q12K7UqeR7sd6joJN9LgGc1d6XQhg/eOUD viktor@gentoo
<h1 class="loader">
<span>З</span>
<span>а</span>
<span>г</span>
<span>р</span>
<span>у</span>
<span>з</span>
<span>к</span>
<span>а</span>
</h1>
@gentoid
gentoid / Gradient 3D text
Created February 16, 2013 15:21
Gradient 3D text (source is http://codepen.io/anon/pen/JzjdL)
<h1 class="text"><span>Gradient 3D text</span></h1>
<style>
body {
background-color: #272727;
}
h1 {
font-family: "Arial", sans-serif;
font-size: 85px;
text-align: center;