Skip to content

Instantly share code, notes, and snippets.

package main

import (
	"crypto/md5"
	//"errors"
	"fmt"
	"io/ioutil"
	"os"
	"path/filepath"
@fhefh2015
fhefh2015 / base64-form-data.js
Created December 26, 2019 03:42 — forked from AshikNesin/base64-form-data.js
Base64 image to multipart/form-data
const base64 = 'data:image/png;base65,....' // Place your base64 url here.
fetch(base64)
.then(res => res.blob())
.then(blob => {
const fd = new FormData();
const file = new File([blob], "filename.jpeg");
fd.append('image', file)
// Let's upload the file
// Don't set contentType manually → https://github.com/github/fetch/issues/505#issuecomment-293064470
@fhefh2015
fhefh2015 / Mojave-nfs.md
Created May 6, 2019 13:44 — forked from LauLaman/Mojave-nfs.md
Vagrant nfs mount Mac OS X Mojave
  1. Mac OS X system settings > Security & Privacy > privacy tab

  2. Select Full Disk Access and click plus icon.

  3. Add terminal in the list ( in my case iTerm)

  4. Restart iTerm

  5. Run command in iterm: $ cd /private/etc && sudo touch ./exports

  6. Start virtual machine trough vargrant: Profit

@fhefh2015
fhefh2015 / macvim
Created October 30, 2018 12:12 — forked from samkahchiin/macvim
- How to set the default font size in macvim
# Open Terminal
vim ~/.vimrc
# Mac OS-X -> .vimrc ; Window -> .gvimrc
# Add it in the file and adjust the font size (h12) accordingly
set guifont=Menlo\ Regular:h15
@fhefh2015
fhefh2015 / MultiPartFromStrings.php
Last active November 27, 2019 02:57 — forked from iansltx/MultiPartFromStrings.php
Multipart file uploads in PHP from strings
/**
* 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.
*
* @param $ch resource curl handle
@fhefh2015
fhefh2015 / html5-video-play-file-blob.html
Created July 5, 2018 14:51 — forked from edin-m/html5-video-play-file-blob.html
HTML video play file blob object url
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<video></video>
<br/>
<input type="file" name="file" id="fileItem" onchange="onChange()" >
@fhefh2015
fhefh2015 / git.md
Created May 27, 2018 15:01 — forked from suziewong/git.md
Git的多账号如何处理? 1.同一台电脑多个git(不同网站的)账号 2.同一台电脑多个git(同一个网站的比如github的)多个账号

1.同一台电脑可以有2个git账号(不同网站的)

首先不同网站,当然可以使用同一个邮箱,比如我的github,gitlab,bitbucket的账号都是monkeysuzie[at]gmail.com 这时候不用担心密钥的问题,因为这些网站push pull 认证的唯一性的是邮箱 比如我的windows 上 2个账号一个gitlab 一个github (用的都是id_rsa)

host github
  hostname github.com
  Port 22

host gitlab.zjut.com

@fhefh2015
fhefh2015 / http-redirect-target.php
Created April 28, 2018 08:00
Get HTTP redirect destination for a URL in PHP
<?php
// FOLLOW A SINGLE REDIRECT:
// This makes a single request and reads the "Location" header to determine the
// destination. It doesn't check if that location is valid or not.
function get_redirect_target($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
@fhefh2015
fhefh2015 / array.class.php
Created January 29, 2018 15:21 — forked from liujingyu/array.class.php
php 数组操作集合
一、数组操作的基本函数
数组的键名和值
array_values($arr); 获得数组的值
array_keys($arr); 获得数组的键名
array_flip($arr); 数组中的值与键名互换(如果有重复前面的会被后面的覆盖)
in_array("apple",$arr); 在数组中检索apple
array_search("apple",$arr); 在数组中检索apple ,如果存在返回键名
array_key_exists("apple",$arr); 检索给定的键名是否存在数组中
isset($arr[apple]): 检索给定的键名是否存在数组中
数组的内部指针
@fhefh2015
fhefh2015 / MultiArraySort.php
Created January 25, 2018 12:55 — forked from lepig/MultiArraySort.php
PHP多维数组按不同字段进行排序
<?php
/**
* PHP数组不定长多键值排序
*
* @author Zjmainstay
* @website http://www.zjmainstay.cn, https://glot.io/snippets/ernfkfnjhb
* @param array $list 数据源
* @param array $rules 排序规则 ['key1'=>'asc', 'key2' => 'desc', ...]
* @return array
*/