Skip to content

Instantly share code, notes, and snippets.

View yasalmasri's full-sized avatar

Yaser Almasri yasalmasri

View GitHub Profile
@yasalmasri
yasalmasri / wled_segmented_notifications.yaml
Last active January 4, 2026 05:34 — forked from Anashost/wled_segmented_notifications.yaml
WLED Notification – Home Assistant Blueprint Turn a WLED strip into a smart notifier: each segment shows custom colors, effects, and brightness for different events, then automatically returns to its original state or a default preset when notifications clear.
blueprint:
name: WLED Segmented Notifications
description: >-
Control up to 4 segments on a single WLED strip for independent notifications.
domain: automation
input:
wled_device:
name: WLED Light Entity
selector:
@yasalmasri
yasalmasri / Calendar.swift
Created January 3, 2026 04:58 — forked from mecid/Calendar.swift
SwiftUI Calendar view using LazyVGrid
import SwiftUI
extension Calendar {
func generateDates(
inside interval: DateInterval,
matching components: DateComponents
) -> [Date] {
var dates: [Date] = []
dates.append(interval.start)
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
@yasalmasri
yasalmasri / delete-channel-messages.js
Created June 25, 2018 18:37 — forked from firatkucuk/delete-slack-messages.js
Deletes slack public/private channel messages.
var https = require('https');
// CONFIGURATION #######################################################################################################
var token = 'SLACK TOKEN';
var channel = 'CHANNEL ID';
var privateChannel = false;
var delay = 300; // delay between delete operations in millisecond
// GLOBALS #############################################################################################################
@yasalmasri
yasalmasri / ios10LocalNotifications.swift
Created March 7, 2017 04:57 — forked from stinger/ios10LocalNotifications.swift
Swift 3: ios10 Local notifications
func showPushNotification(title: String, details: String) {
if #available(iOS 10.0, *) {
let interval = TimeInterval(1)
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: interval, repeats: false)
let content = UNMutableNotificationContent()
content.title = title
content.body = details
let req = UNNotificationRequest(identifier: "localPushNotification", content: content, trigger: trigger)
let center = UNUserNotificationCenter.current()
center.getNotificationSettings(completionHandler: { settings in
@yasalmasri
yasalmasri / gist:0cfa5ba6ee42ab594ed9
Created March 5, 2016 18:12 — forked from trcarden/gist:3295935
Rails 3.2.7 SSL Localhost (no red warnings, no apache config)
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@yasalmasri
yasalmasri / web-server.rb
Created February 6, 2016 22:49 — forked from Integralist/web-server.rb
Create basic Web Server in Ruby (using WEBrick)
#!/usr/bin/env ruby
require "webrick"
=begin
WEBrick is a Ruby library that makes it easy to build an HTTP server with Ruby.
It comes with most installations of Ruby by default (it’s part of the standard library),
so you can usually create a basic web/HTTP server with only several lines of code.
The following code creates a generic WEBrick server on the local machine on port 1234,
@yasalmasri
yasalmasri / point-in-polygon.rb
Last active September 15, 2015 16:07 — forked from kidbrax/point-in-polygon.rb
Check whether a point is within a polygon
def point_in_polygon?(polygonPoints)
return false if self.latitude.blank? or self.longitude.blank?
polygonPoints.each do |point|
point[0] = point[0].to_f
point[1] = point[1].to_f
end
contains_point = false
i = -1
j = polygonPoints.size - 1