Skip to content

Instantly share code, notes, and snippets.

@webkong
webkong / formatDate.js
Last active May 3, 2024 16:38
[JavaScript]snippets for JavaScript #JavaScript
/**
* @description 将时间转换成指定格式
* @param {String|Number} time
* @param {String} fmt
*/
export function timesToDate(time, fmt) {
fmt = fmt || 'yyyy-MM-dd';
time = anyTotime(time);
let date = new Date(time);
if (/(y+)/.test(fmt)) {
@callaginn
callaginn / ajax-contact-form.js
Last active May 3, 2024 16:38
Shopify Ajax Contact Form
// Before implementing this, you'll need to contact Shopify support and ask them to turn off Google's ReCaptcha
// for your Shopify store's contact forms. Otherwise, it will redirect to the captcha's verification page.
// Retrieves input data from a form and returns it as a JSON object:
function formToJSON(elements) {
return [].reduce.call(elements, function (data, element) {
data[element.name] = element.value;
return data;
}, {});
}
// A small test program of me trying Odin + Box2D + Raylib
// Made during this stream: https://www.youtube.com/watch?v=LYW7jdwEnaI
// I used these bindings https://github.com/cr1sth0fer/odin-box2d download them and put them in a sub-folder "box2d" next to this file.
// Then you can build using `odin run .`
package game
import b2 "box2d"
import rl "vendor:raylib"
@gustavomdsantos
gustavomdsantos / AutoHotKey script - Always-on-top.ahk
Last active May 3, 2024 16:32
AutoHotKey script that make any window Always-on-Top on Windows.
; Press Ctrl+Shift+Space to set any currently active window to be always on top.
; Press Ctrl+Shift+Space again set the window to no longer be always on top.
; Source: https://www.howtogeek.com/196958/the-3-best-ways-to-make-a-window-always-on-top-on-windows
^+SPACE::
WinGetTitle, activeWindow, A
if IsWindowAlwaysOnTop(activeWindow) {
notificationMessage := "The window """ . activeWindow . """ is now always on top."
notificationIcon := 16 + 1 ; No notification sound (16) + Info icon (1)
}
@Zekfad
Zekfad / conventional-commits.md
Last active May 3, 2024 16:32
Conventional Commits Cheatsheet

Quick examples

  • feat: new feature
  • fix(scope): bug in scope
  • feat!: breaking change / feat(scope)!: rework API
  • chore(deps): update dependencies

Commit types

  • build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
  • ci: Changes to CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  • chore: Changes which doesn't change source code or tests e.g. changes to the build process, auxiliary tools, libraries
@skoqaq
skoqaq / build4123.sublime4.key
Last active May 3, 2024 16:31
Sublime Text 4 License Key
—– BEGIN LICENSE —–
Mifeng User
Single User License
EA7E-1184812
C0DAA9CD 6BE825B5 FF935692 1750523A
EDF59D3F A3BD6C96 F8D33866 3F1CCCEA
1C25BE4D 25B1C4CC 5110C20E 5246CC42
D232C83B C99CCC42 0E32890C B6CBF018
B1D4C178 2F9DDB16 ABAA74E5 95304BEF
9D0CCFA9 8AF8F8E2 1E0A955E 4771A576
@LeviSnoot
LeviSnoot / discord-timestamps.md
Last active May 3, 2024 16:25
Discord Timestamp Syntax

Discord Timestamps

Discord timestamps can be useful for specifying a date/time across multiple users time zones. They work with the Unix Timestamp format and can be posted by regular users as well as bots and applications.

The Epoch Unix Time Stamp Converter is a good way to quickly generate a timestamp. For the examples below I will be using the Time Stamp of 1543392060, which represents November 28th, 2018 at 09:01:00 hours for my local time zone (GMT+0100 Central European Standard Time).

Formatting

Style Input Output (12-hour clock) Output (24-hour clock)
Default <t:1543392060> November 28, 2018 9:01 AM 28 November 2018 09:01
@FilipSivak
FilipSivak / struct_enum_unreal_engine_python.py
Created January 19, 2022 22:24
Struct and Enum in Unreal Engine python
# Example by Filip Sivak, written for https://filipsivak.medium.com/
import unreal
@unreal.uenum()
class MyPythonEnum(unreal.EnumBase):
FIRST = unreal.uvalue(0)
SECOND = unreal.uvalue(1)
FOURTH = unreal.uvalue(3)
@unreal.ustruct()
@pulsar256
pulsar256 / ssd1306_init.c
Last active May 3, 2024 16:17
SSD 1306 Init Sequence
/**
* according to http://www.adafruit.com/datasheets/UG-2864HSWEG01.pdf Chapter 4.4 Page 15
*/
void ssd1306Init(void)
{
i2c_OLED_send_cmd(0xAE); // Set display OFF
i2c_OLED_send_cmd(0xD4); // Set Display Clock Divide Ratio / OSC Frequency
i2c_OLED_send_cmd(0x80); // Display Clock Divide Ratio / OSC Frequency