Skip to content

Instantly share code, notes, and snippets.

View MohamedBechirMejri's full-sized avatar
🏠
Working from home

Mohamed Bechir Mejri MohamedBechirMejri

🏠
Working from home
View GitHub Profile
@kmaida
kmaida / convert-UNIX-timestamp.js
Last active March 16, 2023 09:31
Convert a UNIX timestamp to user's local time via JavaScript
function convertTimestamp(timestamp) {
var d = new Date(timestamp * 1000), // Convert the passed timestamp to milliseconds
yyyy = d.getFullYear(),
mm = ('0' + (d.getMonth() + 1)).slice(-2), // Months are zero based. Add leading 0.
dd = ('0' + d.getDate()).slice(-2), // Add leading 0.
hh = d.getHours(),
h = hh,
min = ('0' + d.getMinutes()).slice(-2), // Add leading 0.
ampm = 'AM',
time;

Aligning images

This is a guide for aligning images.

See the full Advanced Markdown doc for more tips and tricks

left alignment

@nothingismagick
nothingismagick / caret.js
Last active April 16, 2024 10:09
Small script to detect caret pixel position in contenteditable div
/**
* Get the caret position in all cases
*
* @returns {object} left, top distance in pixels
*/
getCaretTopPoint () {
const sel = document.getSelection()
const r = sel.getRangeAt(0)
let rect
let r2
######## Make any even/odd calculator with this method ########
######################## Get Crazy ###########################
def getCrazy(n)
result = "case x\n"
1..n.times do |number|
result += " when #{number}\n"
result += " p '#{number % 2 == 0 ? 'even': 'odd'}'\n"
🌞 Morning 854 commits █████▎░░░░░░░░░░░░░░░ 25.0%
🌆 Daytime 844 commits █████▏░░░░░░░░░░░░░░░ 24.8%
🌃 Evening 981 commits ██████░░░░░░░░░░░░░░░ 28.8%
🌙 Night 731 commits ████▌░░░░░░░░░░░░░░░░ 21.4%