This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First su in as root | |
sudo su | |
# Then cd to backlight directory | |
cd /sys/class/leds/smc::kbd_backlight/ | |
# Turn the backlight on | |
cat max_brightness > brightness | |
# Set to zero to turn off the backlight |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime, date | |
class DateConverter: | |
regex = '[0-9]{4}-[0-9]{2}-[0-9]{2}' | |
def to_python(self, value: str): | |
return datetime.strptime(value, '%Y-%m-%d').date() | |
def to_url(self, value: date): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
telnet 0.0.0.0 1025 | |
Trying 0.0.0.0... | |
Connected to 0.0.0.0. | |
Escape character is '^]'. | |
220 mailhog.example ESMTP MailHog | |
helo localhost | |
250 Hello localhost | |
mail from: <neil@example.com> | |
250 Sender neil@example.com ok | |
rcpt to: <lisa@example.com> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> isinstance(1, int) | |
True # 👍 | |
>>> isinstance(1, float) | |
False # 👍 | |
>>> isinstance(1.0, int) | |
False # 👍 | |
>>> isinstance(1.0, float) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First su in as root | |
sudo su | |
# Then set fan control to manual mode | |
echo 1 > /sys/devices/platform/applesmc.768/fan1_manual | |
# Then set the fan speed to any value between fan1_min and fan1_max. To view these values | |
cat /sys/devices/platform/applesmc.768/fan1_min | |
cat /sys/devices/platform/applesmc.768/fan1_max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule RomanNumeral do | |
@min_number 1 | |
@max_number 3999 | |
@type to_roman_error() :: :less_than_min_number | :greater_than_max_number | |
@spec to_roman(pos_integer()) :: {:ok, String.t()} | {:error, to_roman_error()} | |
@doc """ | |
Converts a number to a roman numeral. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function() { | |
var adjectives = [ | |
"Autumn", "Hidden", "Bitter", "Misty", "Silent", "Empty", "Dry", "Dark", "Summer", "Icy", | |
"Delicate", "Quiet", "White", "Cool", "Spring", "Winter", "Patient", "Twilight", "Dawn", | |
"Crimson", "Wispy", "Weathered", "Blue", "Billowing", "Broken", "Cold", "Damp", "Falling", | |
"Frosty", "Green", "Long", "Late", "Lingering", "Bold", "Little", "Morning", "Muddy", "Old", | |
"Red", "Rough", "Still", "Small", "Sparkling", "Wandering", "Withered", "Wild", "Black", | |
"Young", "Holy", "Solitary", "Fragrant", "Aged", "Snowy", "Proud", "Floral", "Restless", | |
"Divine", "Polished", "Ancient", "Purple", "Lively", "Nameless"]; | |
var nouns = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
print("""Content-Type: text/html | |
<h1>Hello World</h1>""") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule ListView do | |
@callback query(socket :: Phoenix.LiveView.Socket.t()) :: Ecto.Query.t() | |
defmacro __using__(opts \\ []) do | |
quote bind_quoted: [opts: opts] do | |
opts = Keyword.validate!(opts, [:repo, :schema, :per_page]) | |
@repo Keyword.fetch!(opts, :repo) | |
@schema Keyword.get(opts, :schema) | |
@per_page Keyword.get(opts, :per_page, 10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def chunks(generator, chunk_size): | |
"""Yield successive chunks from a generator""" | |
chunk = [] | |
for item in generator: | |
if len(chunk) >= chunk_size: | |
yield chunk | |
chunk = [item] | |
else: | |
chunk.append(item) |
NewerOlder