Skip to content

Instantly share code, notes, and snippets.

@joseluisq
joseluisq / terminal-git-branch-name.md
Last active May 21, 2024 22:05
Add Git Branch Name to Terminal Prompt (Linux/Mac)

Add Git Branch Name to Terminal Prompt (Linux/Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
@cgrusden
cgrusden / ajaxUpload.js
Created August 1, 2014 01:38
Ajax File Upload
$('input#headshot').on('change', (event) ->
jQuery.active++
files = event.target.files
formData = new FormData()
for file in files
formData.append('images[]', file, file.name)
xhr = new XMLHttpRequest()
xhr.open('POST', $(this).closest('form').attr('action'), true)
@umayr
umayr / promise.js
Last active July 10, 2017 06:29
Promise API example in native javascript
function getGithubUserInfo(username) {
return new Promise(function (resolve, reject) {
// Do the usual XHR stuff
var url = "https://api.github.com/users/" + username;
var req = new XMLHttpRequest();
req.open('GET', url);
req.onload = function () {
@raddeus
raddeus / app.js
Last active May 24, 2023 15:41
Basic Express 4.0 Setup with connect-flash
var express = require('express');
var session = require('express-session');
var cookieParser = require('cookie-parser');
var flash = require('connect-flash');
var app = express();
app.use(cookieParser('secret'));
app.use(session({cookie: { maxAge: 60000 }}));
app.use(flash());
@guweigang
guweigang / git_toturial
Last active May 19, 2024 07:51
git命令大全
git init # 初始化本地git仓库(创建新仓库)
git config --global user.name "xxx" # 配置用户名
git config --global user.email "xxx@xxx.com" # 配置邮件
git config --global color.ui true # git status等命令自动着色
git config --global color.status auto
git config --global color.diff auto
git config --global color.branch auto
git config --global color.interactive auto
git config --global --unset http.proxy # remove proxy configuration on git
git clone git+ssh://git@192.168.53.168/VT.git # clone远程仓库
@suziewong
suziewong / git.md
Last active February 19, 2023 05:38
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

@banago
banago / get-fisrt-paragraph.php
Created November 6, 2012 09:18
Get first paragraph from a WordPress post.
<?php
/**
* Get first paragraph from a WordPress post. Use inside the Loop.
*
* @return string
*/
function get_first_paragraph(){
global $post;
$str = wpautop( get_the_content() );