Skip to content

Instantly share code, notes, and snippets.

@danharper
danharper / CatchAllOptionsRequestsProvider.php
Last active April 20, 2024 01:53
Lumen with CORS and OPTIONS requests
<?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
/**
* If the incoming request is an OPTIONS request
* we will register a handler for the requested route
*/
class CatchAllOptionsRequestsProvider extends ServiceProvider {
@levelsio
levelsio / makebook_obfuscate.php
Last active April 20, 2024 01:51
Obfuscate your ebook so that people who didn't pay can read it, partly
<?php
/*
I wrote this function to progressively obfuscate text in MAKEbook.io. When it KINDA worked, I just used it.
It can take a lot of improvement. I kinda just tweaked the values until it was good enough. It's not SO progressive though.
It takes all the output of your PHP scripts via ob_start(), reroutes that to the obfuscation function.
You should check if user paid for book or not, then either run ob_start or not!
@soheilbm
soheilbm / gist:32d67c3aaad30cf57300d0ad4fd4775c
Last active April 20, 2024 01:52
Install libimobiledevice on OSX
Install libimobiledevice on Mac OS X
So you'd like to manage your iOS devices by command line?
You can use libimobiledevice tools for that.
Easy on Linux. Let's see how it is on Mac OS X.
You'll need to:
1. install Xcode
2. start Xcode and agree to it's license
3. install Xcode command line tools (Start Xcode, Go to Preferences -> Downloads tab)
4. install homebrew by this command (sudo password will be prompted)
;; Challenge: find all the bugs in this small functional compiler
#lang racket
(provide (all-defined-out))
(define verbose-mode (make-parameter #t))
(define i-am-a-mac (make-parameter #f))
;;
;; Our compiler will have several layers
@romiroma
romiroma / Tappable-SwiftUI.swift
Created October 31, 2020 06:06
Tappable Text in SwiftUI
import Foundation
import SwiftUI
struct TappableColoredText: View {
enum Component {
case text(String)
case tappable(String, () -> Void)
}
let components: [Component]
all: build test clean
test:
@echo "========== Internal Domains =========="
dig @127.0.0.1 haas.example.com +short
dig @127.0.0.1 pihole.example.com +short
dig @127.0.0.1 plex.example.com +short
dig @127.0.0.1 go +short
dig @127.0.0.1 modem +short
@carlosleonam
carlosleonam / refresh_dash.php
Last active April 20, 2024 01:39
Snippet to refresh some Dashborad with Adianti Framework ( by Claonilton Junior )
<?php
$script = new TElement('script');
$script->type = 'text/javascript';
$script->add("
$(document).ready(function(){
window.setTimeout(function(){
var results = new RegExp('[\\?&]class=([^&#]*)').exec(window.location.href);
if('".__CLASS__."' == results[1] )
__adianti_load_page('index.php?class=DashboardEmpresa&method=onReload');
@wagners049
wagners049 / reload.php
Last active April 20, 2024 01:37
Adianti Framework - Carregar datagrid somente para grupo administrador
public function onReload($param = NULL)
{
try
{
if( in_array(1, TSession::getValue('usergroupids')) == 1 )
{
// se estiver dentro do grupo admin carrega os dados.
// para incluir usuário específico substituir a condição por if(TSession::getValue('userid') == 1)
}
elseif (empty($_REQUEST['method']) || ($_REQUEST['method'] == 'onShow'))
@carlosleonam
carlosleonam / SaleMultiValueForm.php
Last active April 20, 2024 01:36
Exemplo "Form mestre-detalhe de vendas" do Adianti Tutor 7 - (com algumas correções para funcionar)
<?php
/*
* link original: https://www.adianti.com.br/framework_files/tutor/index.php?class=SaleMultiValueForm
*/
/**
* SaleForm Registration
* @author <your name here>
*/
class SaleMultiValueForm extends TPage
@filewalkwithme
filewalkwithme / main.go
Created February 7, 2015 21:50
Listening multiple ports on golang http servers
package main
import (
"net/http"
)
func main() {
finish := make(chan bool)
server8001 := http.NewServeMux()