This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def separate_name_surnames(full_name): | |
# Creamos una copia del nombre reemplazando todas las partículas | |
modified_name = full_name.lower() | |
particles = ["de la ", "de los ", "de las ", "del ", "de "] | |
for particle in particles: | |
modified_name = modified_name.replace(" " + particle, " " + particle.replace(" ", "_")) | |
# Dividimos el nombre modificado | |
parts = modified_name.split() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Socket | |
; Compile with: nasm -f elf socket.asm | |
; Link with (64 bit systems require elf_i386 option): ld -m elf_i386 socket.o -o socket | |
; Run with: ./socket | |
%include 'functions.asm' | |
SECTION .data | |
; our response string | |
response db 'HTTP/1.1 200 OK', 0Dh, 0Ah, 'Content-Type: text/html', 0Dh, 0Ah, 'Content-Length: 14', 0Dh, 0Ah, 0Dh, 0Ah, 'Hello World!', 0Dh, 0Ah, 0h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
section .text | |
global _start | |
_start: | |
xor eax, eax ; init eax 0 | |
xor ebx, ebx ; init ebx 0 | |
xor esi, esi ; init esi 0 | |
jmp _socket ; jmp to _socket | |
_socket_call: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Get animated polyline route: | |
- https://stackoverflow.com/questions/42620510/how-to-get-animated-polyline-route-in-gmsmapview-so-that-it-move-along-with-map | |
Get polyline from origin and destination coordinates: | |
- https://github.com/lukagabric/LRouteController/blob/master/LRouteControllerSample/Classes/LRouteController/LRouteController.m | |
Draw stroke with some style: | |
var styles:[GMSStrokeStyle] = [GMSStrokeStyle.solidColor(UIColor.cyan), GMSStrokeStyle.solidColor(UIColor.clear)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIViewController { | |
func setAsRootViewController(animated: Bool, completion: (() -> Void)?) { | |
let appDelegate = UIApplication.shared.delegate as? AppDelegate | |
if animated { | |
UIView.transition(with: (appDelegate?.window)!, duration: 0.5, options: .transitionCrossDissolve, | |
animations: { | |
let oldState: Bool = UIView.areAnimationsEnabled | |
UIView.setAnimationsEnabled(false) | |
appDelegate?.window?.rootViewController = self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# First step, prepare the .htpasswd file | |
# Add the user | |
sh -c "echo -n 'USERNAME:' >> /etc/nginx/.htpasswd" | |
# Then, add the password | |
sh -c "openssl passwd -apr1 >> /etc/nginx/.htpasswd" | |
# Now, add it to your location |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This task will run for ever a task get 0% of cpu | |
// dont use waitUntil because it will consume you cpu | |
import Foundation | |
extension Task { | |
public func waitUntilWithSleep() { | |
while running { | |
// sleep for 0.1 seconds | |
usleep(10000) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Avoid usage of files with this characters. | |
Examples with positive response: | |
/var/www/templates/../../../etc/passwd | |
/var/www/templates/%2e%2e%2f%2e%2e%2f%2e%2e%2fetc/passwd | |
/var/www/templates%252e%252e%252f%252e%252e%252f%252e%252e%252fetc/passwd | |
/var/www/templates/..%c0%af..%c0%af..%c0%afetc/passwd | |
With this you cannot do things like this: | |
/var/www/templates/.htdocs (because /. is not allowed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Very slightly adapted from http://stackoverflow.com/a/30141700/106244 | |
// 99.99% Credit to Martin R! | |
// Mapping from XML/HTML character entity reference to character | |
// From http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references | |
private let characterEntities : [String: Character] = [ | |
// XML predefined entities: | |
""" : "\"", | |
"&" : "&", |