Skip to content

Instantly share code, notes, and snippets.

View php-coder's full-sized avatar

Slava Semushin php-coder

View GitHub Profile
@willurd
willurd / web-servers.md
Last active July 6, 2024 23:56
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@marcusphi
marcusphi / ansible_conditionals_examples.yaml
Created October 2, 2013 09:48
Ansible 1.3 Conditional Execution -- Very complete example with comments -- I find the conditional expressions to be ridiculously hard to get right in Ansible. I don't have a good model of what's going on under the surface so I often get it wrong. What makes it even harder is that there has been at least three different variants over the course …
---
# This has been tested with ansible 1.3 with these commands:
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts isFirstRun=false"
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts isFirstRun=true"
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts"
# NB: The type of the variable is crucial!
- name: Ansible Conditionals Examples
hosts: $hosts
vars_files:
@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@wbsch
wbsch / on-modify.blocks_attr.py
Last active May 20, 2024 20:46
Taskwarrior hook script that adds a "blocks:" pseudo-attribute for adding/modifying tasks.
#!/usr/bin/env python
#
# Adds the ability to add / modify tasks using a "blocks:" attribute,
# the opposite of "depends:".
#
# This script acts as an on-modify, on-add and on-launch hook at the same time.
#
### SETUP
# Save this file as
# ~/.task/hooks/on-modify.blocks_attr.py
@PurpleBooth
PurpleBooth / README-Template.md
Last active July 6, 2024 04:11
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

http://ernestmicklei.com.s3-website-eu-west-1.amazonaws.com/2012/11/go-restful-api-design/
http://dukex.svbtle.com/manage-golang-dependencies
https://engineering.canva.com/2015/08/25/how-we-get-things-done/
https://apiblueprint.org/
http://www.gofpatterns.com/design-patterns/module3/intro-singleton-design-pattern.php
http://www.hydrogen18.com/blog/stop-listening-http-server-go.html
http://soryy.com/blog/2014/common-mistakes-with-go-lang/
https://howistart.org/posts/go/1
https://talks.golang.org/2013/bestpractices.slide#1
http://peter.bourgon.org/go-in-production/
#!/bin/bash
oc cluster down
docker rm -f bindmountproxy
@andreldm
andreldm / AprConfiguration.java
Created February 1, 2017 12:24
APR on Spring Boot
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.core.AprLifecycleListener;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* NOTE: You also need to install APR on your system, on Arch Linux the package is called `tomcat-native`.
@stefan-huettemann
stefan-huettemann / RestTemplate-Multipart.java
Last active February 6, 2024 21:19
Multipart Request using spring RestTemplate
protected ResponseEntity<Resource<List<Attachment>>> patchMultipartApiV1_Treatments_TID(final String aTID,
final Treatment aTreatment,
final boolean keepLock,
final MultipartFile... aMultipartFiles) throws IOException {
final MultiValueMap<String, Object> theMultipartRequest = new LinkedMultiValueMap<>();
// creating an HttpEntity for the JSON part:
final HttpHeaders theJsonHeader = new HttpHeaders();
theJsonHeader.setContentType(MediaType.APPLICATION_JSON);
@enricofoltran
enricofoltran / main.go
Last active June 26, 2024 12:16
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"