Skip to content

Instantly share code, notes, and snippets.

View DRFR0ST's full-sized avatar
🏡
Not on vacation

Mike Eling DRFR0ST

🏡
Not on vacation
View GitHub Profile
@DRFR0ST
DRFR0ST / highTempAlert.sh
Created December 15, 2018 14:15
Sends a notification when the GPU temperature is over +85°C
#!/bin/bash
while true; do
real=$(sensors | grep 'temp1' | grep -oP -m 1 "\+\d{2}.\d°C" | head -1 | gre$
high=85
if [ "$real" -ge "$high" ];then
notify-send "The temperature of GPU is very high! (+$real°C)"
sleep 60
else
sleep 5
@DRFR0ST
DRFR0ST / README.md
Created January 3, 2019 17:00 — forked from addyosmani/README.md
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@DRFR0ST
DRFR0ST / FlexWrapper.js
Last active March 5, 2019 11:49
Flexbox wrapper component for React
import React, { PureComponent } from "react";
import PropTypes from "prop-types";
/**
* @class
* @description Simple Flexbox wrapper.
* @author Mike Eling <mike.eling97@gmail.com>
*/
class FlexWrapper extends PureComponent {
/**
@DRFR0ST
DRFR0ST / FlexWrapper.js
Created March 9, 2019 14:27
Flexbox wrapper for React Native
import React, { PureComponent } from "react";
import { View } from "react-native";
import PropTypes from "prop-types";
/**
* @class
* @description Simple Flexbox wrapper.
* @author Mike Eling <mike.eling97@gmail.com>
*/
class FlexWrapper extends PureComponent {
@DRFR0ST
DRFR0ST / Get highlighted text
Last active September 6, 2019 16:07
Returns highlighted text (component) by passing it the text and an array of strings which will be highlighted. (React)
function getHighlightedText(text, highlights) {
let parts = text.split(new RegExp(`(${highlights.join("|")})`, "gi"));
return (
<span>
{parts.map((part, i) => (
<span
key={i}
style={highlights.indexOf(part) > -1 ? { fontWeight: "bold" } : {}}>
{part}
</span>
<div>
<h1>This are the terms of my service</h1>
<h3>Consider having no problems at all with it</h3>
<ol>
<li><a href="#foo">Foo</a></li>
<li><a href="#bar">Bar</a></li>
<li><a href="#baz">Baz</a></li>
<li><a href="#qux">Qux</a></li>
</ol>
(() => {
// Interval, wykonuje się co 400 ms.
setInterval(() => {
// Sprawdza czy cookie "interface" ma ustawioną wartość "si".
const isSi = getCookie("interface") == "si" ? true : false;
// Sprawdza czy użytkownik jest away from the keyboard.
const afk = isSi ? hero.stasis : Engine.hero.d.stasis;
// Sprawdza czy użytkownik dedł.
const dead = isSi ? g.dead : Engine.dead;
// Sprawdza czy użytkownik się napitala.
@DRFR0ST
DRFR0ST / freezer.ts
Last active May 11, 2020 14:13
🧊 Keep your data ice cold
/**
* Freeze your object with this Freezer.
* @author Me or You
* @param roomTemperatureData Data for super cooling.
* @example Freezer({ value: "foo" }, { name: "bar" });
* @returns Frozen as hell data.
*/
const Freezer = (...roomTemperatureData: Object[]) => Object.freeze( roomTemperatureData.map(item => Object.freeze(item) ) );
/**
* Returns a function that delays callback.
*/
const useDelay = () => {
const ref = useRef<(fn: Function, ms: number) => void | null>(null);
if(ref.current === null) {
let t = -1;
const delay = (fn: Function, ms: number) => {
clearTimeout(t);
@DRFR0ST
DRFR0ST / useConnectivity.ts
Last active May 20, 2020 11:01
🎣 React Native hook for checking internet connection.
import { useRef, useState } from 'react';
import NetInfo from "@react-native-community/netinfo";
/**
* Returns information about internet connectivity.
* @example const [isConnected, checkConnection] = useConnectivity();
*/
export const useConnectivity = () => {
const [ isConnected, setConnected ] = useState<boolean | null>(null);
const ref = useRef<[ typeof isConnected, () => void ] | null>(null);