Skip to content

Instantly share code, notes, and snippets.

Avatar
🔥
building blazing.report - reimagine mobile analytics

Nedim nedimf

🔥
building blazing.report - reimagine mobile analytics
View GitHub Profile
@nedimf
nedimf / adding-cors-to-to-grpc-gateway.md
Created Jan 24, 2022
Adding CORS rules to grpc-gateway generated API
View adding-cors-to-to-grpc-gateway.md

Issue

Access to XMLHttpRequest at 'http://localhost:8081/create/account' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Solution

important: please inform your self on safety behind CORS before adding this to your project

func allowCORS(h http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		if origin := r.Header.Get("Origin"); origin != "" {
@nedimf
nedimf / truncate+string.swift
Last active Nov 21, 2020
Truncate string and add "..." in the end - SWIFT
View truncate+string.swift
//Extension on String
extension String {
func truncating(max:Int) -> String{
let text = self
print("passed text \(text)")
if text.count >= max {
let truncatedIndex = text.index((text.startIndex), offsetBy: max)
@nedimf
nedimf / cannot-unmarshal-dns-message-for-srv-lookup.md
Last active Nov 7, 2020
"cannot unmarshal DNS message" for SRV lookup MongoDB
View cannot-unmarshal-dns-message-for-srv-lookup.md

Issue

 "cannot unmarshal DNS message" for SRV lookup

this gists won't go over DNS setup part for +srv to work

When you google this error, you will get something few results, one of which is this. If you are not using Docker that one will actually not help you, but will definitly give you perspective on a problem.

What does it mean?

View FontNames-iOS12.swift
/*
*** Academy Engraved LET ***
AcademyEngravedLetPlain
---------------------
*** Al Nile ***
AlNile
AlNile-Bold
---------------------
*** American Typewriter ***
AmericanTypewriter
View hapticFeedback.swift
func hapticFeedback(for haptic: UINotificationFeedbackGenerator.FeedbackType){
let generator = UINotificationFeedbackGenerator()
generator.notificationOccurred(haptic)
}
@nedimf
nedimf / coffee.py
Created Nov 9, 2019
Reminder for coffee break (Linux&Python)
View coffee.py
import threading
import notify2
def coffee():
threading.Timer(3600.0, coffe).start() #3600 seconds equals an hour
print ("Break!")
notify2.init('Reminder')
n = notify2.Notification('COFFE BREAK','Time for little break,you have been working really hard!') #Also you can costumize this part for your own message
n.show()
coffee()
@nedimf
nedimf / pascal_shell.py
Created Aug 31, 2019
Wraper for FCP (Pascal compiler) on Linux
View pascal_shell.py
#!usr/bin/python
# Developer : @nedimf
import sys
import os
from cmd import Cmd
import subprocess
from colorama import Fore,Back,Style
import signal
#Declaration of variables