Skip to content

Instantly share code, notes, and snippets.

@yeknava
yeknava / gist:25c771d6c3baf233b4a7d5287ddb0000
Created July 1, 2022 07:39
kde open application menu with Meta key
kwriteconfig5 --file ~/.config/kwinrc --group ModifierOnlyShortcuts --key Meta "org.kde.plasmashell,/PlasmaShell,org.kde.PlasmaShell,activateLauncherMenu"
@yeknava
yeknava / publishWithRespect.php
Created September 20, 2020 21:37
Laravel publish files with new namespaces
<?php
use Illuminate\Support\ServiceProvider;
class SampleServiceProvider extends ServiceProvider {
public function boot() {
$this->publishWithRespect([
dirname(__DIR__, 1) . '/src/Models/' => [
'path' => config('package.models_path'),
@yeknava
yeknava / doc.php
Last active December 27, 2020 21:18
Simple api document generator for laravel actions:
<?php
/**
only works for routes that using laravel action's[1] invoke
as handler. result consists of route's name,
uri, method and action's rules.
1) https://github.com/lorisleiva/laravel-actions
*/
use Illuminate\Support\Facades\Route;
@yeknava
yeknava / pwaInstall.js
Created August 19, 2020 14:25
pwa install
let deferredPrompt = null;
let installed = false;
let initiated = false;
export default {
init() {
initiated = true;
window.addEventListener('beforeinstallprompt', (e) => {
// Prevent Chrome 67 and earlier from automatically showing the prompt
e.preventDefault();
@yeknava
yeknava / letsencrypt_2018.md
Created September 1, 2018 14:41 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@yeknava
yeknava / ProgressBar.js
Last active September 23, 2016 10:45
React Native Progress Bar Component
````
import React, { Component } from 'react';
import { Text, View, StyleSheet } from 'react-native';
export default class ProgressBar extends Component {
constructor(props) {
super(props);
this.state = {
};
}
$ncode = '0011111111';
$ncodeArray = str_split($ncode);
$sum = 0;
for($i=0; $i<10; $i++) {
$sum = intval($ncodeArray[$i])*($i+1);
}
$mod11 = $sum%11;
if($mod11 < 2) {
if(intval($mod11) === intval($ncodeArray[9])) {
return true;
$ncode = '0011111111';
$ncodeArray = str_split($ncode);
$sum = 0;
for($i=0; $i<10; $i++) {
$sum = intval($ncodeArray[$i])*($i+1);
}
$mod11 = $sum%11;
if($mod11 < 2) {
if(intval($mod11) === intval($ncodeArray[9])) {
return true;
var baseUrl = 'http://localhost:9900/';
var buildUrl = function(path) {
return baseUrl+path;
}
var request = function(method, path, data, callback) {
var datatype = "json";
url = buildUrl(path);
console.log("---------REQUEST TO "+url+" WITH method "+method);
@yeknava
yeknava / getcookie.go
Last active December 27, 2021 00:22
Golang get cookie by name
func getCookieByName(cookie []*http.Cookie, name string) string {
cookieLen := len(cookie)
result := ""
for i := 0; i < cookieLen; i++ {
if cookie[i].Name == name {
result = cookie[i].Value
}
}
return result
}