Skip to content

Instantly share code, notes, and snippets.

1 sudo nano /etc/default/grub
2 There is a line in that: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" (like this), replace with: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_idle.max_cstate=1"
3 Save it (CTRL+O)
4 sudo update-grub
5 sudo reboot
@tonis2
tonis2 / gist:32bde0938b2c9cdbe44ab0317a7ec7fe
Created January 29, 2019 10:46
Golang struct to graphql schema
func makeSchemaValues(Types interface{}) (graphql.Fields, graphql.FieldConfigArgument) {
fields := make(graphql.Fields)
args := make(graphql.FieldConfigArgument)
val := reflect.ValueOf(Types)
if val.Kind() == reflect.Ptr {
val = reflect.Indirect(val)
@tonis2
tonis2 / gist:7975cab032cb7703a3572b31bb97599f
Created December 13, 2018 21:36
Caylel, save data and load with graphql
package main
import (
"bytes"
"context"
"encoding/json"
"fmt"
"log"
"math/rand"
"strings"
Thanks to ///https://medium.com/@ryardley/react-hooks-not-magic-just-arrays-cd4f1857236e
let state = [];
let setters = [];
let firstRun = true;
let cursor = 0;
function createSetter(cursor) {
return function setterWithCursor(newVal) {
state[cursor] = newVal;
@tonis2
tonis2 / gist:43d8003a9237adbb4adad68d46202240
Last active September 29, 2018 08:48
Regex exercise interview question
/*
write a function that takes two inputs:
 vocabulary - array of strings (words)
 sentence - string
and returns:
 true - if the sentence can be split in the words given; words can be repeated, words can have any order; you can use only subset of words
 false - if the sentence cannot be split in the words
@tonis2
tonis2 / gist:9f87420a12e409009761a45b5787e156
Created July 4, 2018 12:00
UPLOAD to FIREBASE storage with REST API
### Add security rule for public access
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write;
}
}
}
@tonis2
tonis2 / gist:7639afe88a6b27ca4eca5223797e70b5
Created June 25, 2018 11:36
Send mail with node.js and ssmtp
const emails = "email1@gmail.com"
const msg = `<p><span>msg:${req.body.msg}</span> <br /> <span>url:${req.body.url}</span> <br /> <span>line:${req.body.lineNo}</span> <br /> <span>column:${req.body.columnNo}</span> <br /> error:${req.body.error}</p>`;
exec.exec(`echo "From:where.dev@gmail.com\r\nDate: $(date)\r\nSubject:website crash report\r\nMIME-Version: 1.0\r\nContent-Type: text/html; charset=utf-8\r\n\r\n ${msg}" | sudo ssmtp -vvv -C ssmpt2.conf -ap 55604881 -F " Pro error" ${emails}`, (err, stdout, stderr) => {
if (err) {return;}
});
@tonis2
tonis2 / gist:d67c91bd69e389dccc9556266910d199
Created June 15, 2018 22:06
Rust where clause example
struct Moose {
name: String
}
struct Deer {
name: String
}
trait Actions {
fn baby_name(&self) -> String;
@tonis2
tonis2 / gist:3b07ea8b0a1f30d0e30c3a0bb4112349
Last active June 8, 2018 12:48
rust rock, scissors, papers.
extern crate rand;
use rand::prelude::*;
use std::collections::HashMap;
use std::io::{stdin, stdout, Write};
fn main() {
let mut game_values: HashMap<&str, i32> = HashMap::new();
game_values.insert("kivi", 1);
use svg <svg class="twitter-icon">
<use xlink:href="path/to/icons.svg#twitter-icon"></use>
<svg>