Skip to content

Instantly share code, notes, and snippets.

👻
wandering

May aprilandjan

👻
wandering
Block or report user

Report or block aprilandjan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View BeginningOpenGl.md

Travel Guide to OpenGL

I've figured out several things while trying to extend my knowledge of Computer Graphics.

  1. OpenGL can be a bitch if you don't know what you're doing.
  2. There is no worse pain than to experience CMake without knowing what you're doing.
  3. When walking to the depths of hell, it would be nice to have a travel guide.

And that's what this is, a travel guide.

@aprilandjan
aprilandjan / utils.ts
Created Apr 2, 2019
hand-made, lightweight utility functions to do value operations.
View utils.ts
/**
* test if the target is an object(array included)
*/
export function isObject(obj: any): boolean {
return obj !== null && typeof obj === 'object';
}
/** simple deep equal */
export function isEqual(a: any, b: any): boolean {
if (isObject(a) && isObject(b)) {
@aprilandjan
aprilandjan / better-nodejs-require-paths.md
Created Jan 31, 2019 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js
View better-nodejs-require-paths.md

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@aprilandjan
aprilandjan / multiple_ssh_setting.md
Created Jan 4, 2019 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts
View multiple_ssh_setting.md

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@aprilandjan
aprilandjan / object-to-form-data.js
Created Aug 29, 2018 — forked from ghinda/object-to-form-data.js
JavaScript Object to FormData, with support for nested objects, arrays and File objects. Includes Angular.js usage.
View object-to-form-data.js
// takes a {} object and returns a FormData object
var objectToFormData = function(obj, form, namespace) {
var fd = form || new FormData();
var formKey;
for(var property in obj) {
if(obj.hasOwnProperty(property)) {
if(namespace) {
@aprilandjan
aprilandjan / mixins.scss
Created Jun 22, 2017
A collection of useful sass mixins
View mixins.scss
/* flex 居中 */
@mixin centering {
display: flex;
justify-content: center;
align-items: center;
}
/* css 绘制的关闭按钮 */
@mixin cssClose ($width, $height, $color) {
position: relative;
View webpack-require-context.js
function requireAll(requireContext) {
var result = {}
requireContext.keys().forEach(path => {
var name = path.replace(/^.*(\\|\/|\:)/, '').split('.')[0]
result[name] = requireContext(path)
})
return result
}
var modules = requireAll(require.context("./api", false, /^\.\/.*\.js$/))
View ua.js
var userAgent = window.navigator.userAgent.toLowerCase()
var ua = {
isIOS: userAgent.match(/iphone|ipad|ipod/i),
isAndroid: userAgent.match(/android/i),
isWechat: userAgent.match(/micromessenger/i),
isWeibo: userAgent.match(/weibo/i),
isQQ: userAgent.match(/qq/i),
isMobile: userAgent.match(/iphone|ipad|ipod|android/i)
}
@aprilandjan
aprilandjan / slugify.js
Last active Apr 14, 2017 — forked from mathewbyrne/slugify.js
Javascript Slugify
View slugify.js
function slugify(text)
{
return text.toString().trim().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
// .replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/[^a-zA-Z0-9_\u3400-\u9FBF\s-]/g,'') // remove all non-word & non-chinese chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
}
You can’t perform that action at this time.