Skip to content

Instantly share code, notes, and snippets.

View juwencheng's full-sized avatar
🏠
Working from home

Juwencheng juwencheng

🏠
Working from home
View GitHub Profile
@branflake2267
branflake2267 / main.dart
Last active June 22, 2022 02:41
Flutter fonts example use.
import 'package:flutter/material.dart';
const String words1 = "Almost before we knew it, we had left the ground.";
const String words2 = "A shining crescent far beneath the flying vessel.";
const String words3 = "A red flair silhouetted the jagged edge of a wing.";
const String words4 = "Mist enveloped the ship three hours out from port.";
void main() {
runApp(new MyApp());
}
@tonymtz
tonymtz / gist:d75101d9bdf764c890ef
Last active July 26, 2024 20:17
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@kkdai
kkdai / mgo-go-query-sample.go
Created August 6, 2014 16:15
go- mongoDB mgo insert and query greater than sample
package main
import (
"fmt"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
type msg struct {
// Msg string `bson:"msg"`
@mattes
mattes / check.go
Last active August 21, 2024 04:51
Check if file or directory exists in Golang
if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) {
// path/to/whatever does not exist
}
if _, err := os.Stat("/path/to/whatever"); !os.IsNotExist(err) {
// path/to/whatever exists
}
@billyohgren
billyohgren / UILabel+ContentSize.h
Last active April 20, 2020 13:04
Calculate the actual size of the content inside a UILabel
#import <UIKit/UIKit.h>
@interface UILabel (ContentSize)
- (CGSize)contentSize;
@end
@aegzorz
aegzorz / NSObject+LogDealloc.h
Last active October 16, 2021 13:08
Category on NSObject that logs deallocs, useful when tracking down memory leaks
#import <Foundation/Foundation.h>
@interface NSObject (LogDealloc)
- (void)logOnDealloc;
@end
@brasofilo
brasofilo / mu-plugin-disable-admin.php
Last active December 12, 2018 12:34
Disable wp-admin and wp-login
<?php
/*
Plugin Name: Disable Admin and Login
Plugin URI: http://wordpress.stackexchange.com/a/106437/12615
Requires: PHP 5.3
*/
add_action( 'init', function()
{
$currentURL = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
@willurd
willurd / web-servers.md
Last active September 21, 2024 09:18
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
@jxson
jxson / README.md
Created February 10, 2012 00:18
README.md template

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Motivation