Skip to content

Instantly share code, notes, and snippets.

Rustの演算子の優先順位 Operator precedence

  • 次の表で、演算子を優先順位降順に並べる。
    • 単項演算子は二項演算子より優先されることが分かる。
      • より正確には、後置単項演算子 > 前置単項演算子 > 二項演算子 の順。
    • 「非結合」演算子では、その結合を丸括弧 (,) で明示しないと文法エラーとなる。
      • a == b == c - Error
      • (a == b) == c - OK
  • フィールド演算子.?より強い。よって &self.hoge?&((self.hoge)?)となる。
@OrionReed
OrionReed / dom3d.js
Last active May 5, 2024 14:09
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@NazimCodes
NazimCodes / SnakeGame.cpp
Last active May 5, 2024 14:06
Snake Game made out of C++
/* Snake Game using C++
developed by TheKittyKat,
improved by Nazim Nazari
December 2017 */
#include <iostream>
#include <conio.h>
using namespace std;
void run();
@thiamsantos
thiamsantos / db-conventions.md
Last active May 5, 2024 14:03
Convenções de nomenclatura para banco de dados

Convenções de nomenclatura para banco de dados

Geral

Os nomes das tabelas e colunas devem estar minúsculas e as palavras devem ser separadas por underscore, seguindo o padrão snake case. E todos os termos devem estar em inglês, exceto alguns termos que não há tradução apropriada para o inglês. Sempre prefira nomes descritivos, evitando ao máximo contrações.

Tabelas

Os nomes das tabelas devem estar no plural.

@primaryobjects
primaryobjects / hotspot-keep-alive.ps1
Last active May 5, 2024 14:03
Script to Enable Windows 10 Mobile Hotspot Automatically After Reboot
# https://superuser.com/a/1434648
Add-Type -AssemblyName System.Runtime.WindowsRuntime
$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0]
Function Await($WinRtTask, $ResultType) {
$asTask = $asTaskGeneric.MakeGenericMethod($ResultType)
$netTask = $asTask.Invoke($null, @($WinRtTask))
$netTask.Wait(-1) | Out-Null
$netTask.Result
@c5inco
c5inco / HeartRate.kt
Last active May 5, 2024 14:03
Jetpack Compose implementation of inspiration: https://twitter.com/amos_gyamfi/status/1494053914945236999
package des.c5inco.material3
import android.graphics.Matrix
import android.graphics.Path
import androidx.compose.animation.core.*
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.size
@gwangjinkim
gwangjinkim / install-and-start-postgresql-in-conda-locally
Last active May 5, 2024 14:02
How to install and run postgresql in conda
This gist I write, because I couldn't find step by step instructions
how to install and start postgresql locally (using conda within a conda environment - with the result
that you can run it without sudo/admin rights on your machine!)
and not globally in the operating system (which requires sudo/admin rights on that machine).
I hope, this will help especially people new to postgresql (and those who don't have sudo/admin rights on a specific machine but want
to run postgresql there)!
####################################
# create conda environment
@n1snt
n1snt / Oh my ZSH with zsh-autosuggestions zsh-syntax-highlighting zsh-fast-syntax-highlighting and zsh-autocomplete.md
Last active May 5, 2024 13:57
Oh my ZSH with zsh-autosuggestions zsh-syntax-highlighting zsh-fast-syntax-highlighting and zsh-autocomplete.md

Oh my zsh.

Oh My Zsh

Install ZSH.

sudo apt install zsh-autosuggestions zsh-syntax-highlighting zsh

Install Oh my ZSH.

@isasharafdin
isasharafdin / npm-downloads-increaser.mjs
Created May 5, 2024 13:53
🚀 Boost Your npm Package Downloads with the npm Downloads Increaser! Designed to maximize the visibility and appeal of your npm packages, this tool helps you effectively promote your project to a larger audience. Ideal for developers looking to increase their project's impact during launches or community highlights. Please use ethically and in a…
import https from 'https'; // Import the https module to make HTTPS requests
import readline from 'readline'; // Import the readline module for interactive command line interfaces
// Create a readline interface for user input from the command line
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
/**
import llama_cpp
import re
import json
# Model configuration
# tested with mistral, llama2, llama3, and phi3
model_path = "/path/to/model"
base_llm = llama_cpp.Llama(model_path, seed=42, n_gpu_layers=-1, n_ctx=4096, verbose=False, temperature=0.0)