Skip to content

Instantly share code, notes, and snippets.

View mashirozx's full-sized avatar
🐕
Just for fun

Mashiro mashirozx

🐕
Just for fun
View GitHub Profile
@dciccale
dciccale / git_branch.sh
Created May 11, 2013 18:02
Bash script to get the current git branch and last commit
#!/usr/bin/env bash
# checks if branch has something pending
function parse_git_dirty() {
git diff --quiet --ignore-submodules HEAD 2>/dev/null; [ $? -eq 1 ] && echo "*"
}
# gets the current git branch
function parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
@liuzhe0223
liuzhe0223 / upload_image.py
Created June 25, 2013 11:08
用于上传图片到 https://api.imgur.com , 返回图片url, 论坛发图片用的
#!/usr/bin/python2
import urllib2
import urllib
import sys
import json
try:
data = file(sys.argv[1], 'r').read()
except:
@pauloricardomg
pauloricardomg / cors.nginxconf
Last active March 8, 2024 18:31
Nginx configuration for CORS-enabled HTTPS proxy with origin white-list defined by a simple regex
#
# Acts as a nginx HTTPS proxy server
# enabling CORS only to domains matched by regex
# /https?://.*\.mckinsey\.com(:[0-9]+)?)/
#
# Based on:
# * http://blog.themillhousegroup.com/2013/05/nginx-as-cors-enabled-https-proxy.html
# * http://enable-cors.org/server_nginx.html
#
server {
@bmcbride
bmcbride / deleteFromImgur.js
Last active May 25, 2022 17:53
Upload image from HTML form to http://imgur.com/
function deleteFromImgur() {
$.ajax({
url: "https://api.imgur.com/3/image/{id}",
type: "DELETE",
headers: {
"Authorization": "Client-ID YOUR-CLIEND-ID-GOES-HERE"
},
success: function(response) {
//console.log(response);
}
@jondlm
jondlm / diff_recursive.php
Last active July 18, 2021 02:37
Recursive array diff php
<?php
/*
* Recursively diff two arrays. This function expects the leaf levels to be
* arrays of strings or null
*/
function diff_recursive($array1, $array2) {
$difference=array();
foreach($array1 as $key => $value) {
if(is_array($value) && isset($array2[$key])){ // it's an array and both have the key
$new_diff = diff_recursive($value, $array2[$key]);
@brianclements
brianclements / Commit Formatting.md
Last active November 6, 2024 18:03
Angular Commit Format Reference Sheet

Commit Message Format

This specification is inspired by and supersedes the [AngularJS commit message format][commit-message-format].

We have very precise rules over how our Git commit messages must be formatted. This format leads to easier to read commit history.

Each commit message consists of a header, a body, and a footer.

@ygmpkk
ygmpkk / Dockerfile
Created February 23, 2015 09:55
dockerfile source list
FROM ubuntu:14.04
ENV DEBIAN_FRONTEND noninteractive
##///*******************************************************/
##//------------------------
## append apt mirror for ubuntu, update & install
##//------------------------
## RUN sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list
RUN echo "deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse" > /etc/apt/sources.list
RUN echo "deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse" >> /etc/apt/sources.list
RUN echo "deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse" >> /etc/apt/sources.list
@iansltx
iansltx / MultiPartFromStrings.php
Created May 2, 2015 03:31
Multipart file uploads in PHP from strings
<?php
/**
* PHP's curl extension won't let you pass in strings as multipart file upload bodies; you
* have to direct it at an existing file (either with deprecated @ syntax or the CURLFile
* type). You can use php://temp to get around this for one file, but if you want to upload
* multiple files then you've got a bit more work.
*
* This function manually constructs the multipart request body from strings and injects it
* into the supplied curl handle, with no need to touch the file system.
@tomieric
tomieric / css-filp.css
Created March 21, 2016 01:38
全兼容css水平翻转
/*
* by zhangxinxu
* http://www.zhangxinxu.com/wordpress/2011/05/css%E5%AE%9E%E7%8E%B0%E5%90%84%E4%B8%AA%E6%B5%8F%E8%A7%88%E5%99%A8%E5%85%BC%E5%AE%B9%E7%9A%84%E5%9E%82%E7%9B%B4%E7%BF%BB%E8%BD%AC%E6%B0%B4%E5%B9%B3%E7%BF%BB%E8%BD%AC%E6%95%88%E6%9E%9C/
*/
/*水平翻转*/
.flipx {
-moz-transform:scaleX(-1);
-webkit-transform:scaleX(-1);
-o-transform:scaleX(-1);
transform:scaleX(-1);
@gkhays
gkhays / DrawSineWave.html
Last active November 12, 2024 16:29
Oscillating sine wave, including the steps to figuring out how to plot a sine wave
<!DOCTYPE html>
<html>
<head>
<title>Sine Wave</title>
<script type="text/javascript">
function showAxes(ctx,axes) {
var width = ctx.canvas.width;
var height = ctx.canvas.height;
var xMin = 0;