Skip to content

Instantly share code, notes, and snippets.

Darcy Liu darcyliu

Block or report user

Report or block darcyliu

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 install_spark_centos7.sh
#!/bin/bash
# Install Spark on CentOS 7
yum install java -y
java -version
yum install wget -y
wget http://downloads.typesafe.com/scala/2.11.7/scala-2.11.7.tgz
tar xvf scala-2.11.7.tgz
sudo mv scala-2.11.7 /usr/lib
sudo ln -s /usr/lib/scala-2.11.7 /usr/lib/scala
@darcyliu
darcyliu / centos7_timechine.sh
Last active Jul 9, 2019
Install Time Machine service on CentOS 7
View centos7_timechine.sh
# Install Time Machine service on CentOS 7
# http://netatalk.sourceforge.net/wiki/index.php/Netatalk_3.1.7_SRPM_for_Fedora_and_CentOS
# http://confoundedtech.blogspot.com/2011/07/draft-draft-ubuntu-as-apple-time.html
yum install -y rpm-build gcc make wget
# install netatalk
yum install -y avahi-devel cracklib-devel dbus-devel dbus-glib-devel libacl-devel libattr-devel libdb-devel libevent-devel libgcrypt-devel krb5-devel mysql-devel openldap-devel openssl-devel pam-devel quota-devel systemtap-sdt-devel tcp_wrappers-devel libtdb-devel tracker-devel
yum install -y bison docbook-style-xsl flex dconf
View hello.cpp
// mutex example
// clang++ hello.cpp -std=c++11 -o hello
#include <iostream> // std::cout
#include <thread> // std::thread
#include <mutex> // std::mutex
std::mutex mtx; // mutex for critical section
void print_block (int n, char c) {
// critical section (exclusive access to std::cout signaled by locking mtx):
@darcyliu
darcyliu / attribute.c
Created Jul 2, 2019
Clang constructor and destructor attributes
View attribute.c
// clang attribute.c -o attribute
#include <stdio.h>
int main(int argc, char *argv[]) {
printf("Hello World!\n");
return 0;
}
__attribute__((constructor)) static void beforeFunction()
{
printf("beforeFunction\n");
@darcyliu
darcyliu / centos7_samba.sh
Created Jun 10, 2016
Samba install script for CentOS 7
View centos7_samba.sh
#!/bin/sh
# Samba install script for CentOS 7
yum install -y samba samba-client samba-common
mv /etc/samba/smb.conf /etc/samba/_smb.conf
cat >> /etc/samba/smb.conf << EOF
[global]
workgroup = WORKGROUP
server string = Samba Server %v
@darcyliu
darcyliu / install_mlpack_osx.sh
Created Mar 31, 2016
Install mlpack on OSX 10.11 (EI Capitan)
View install_mlpack_osx.sh
#!/bin/bash
# Install mlpack on OSX 10.11 (EI Capitan)
curl -O http://tenet.dl.sourceforge.net/project/arma/armadillo-6.500.5.tar.gz
tar zxvf armadillo-6.500.5.tar.gz
cd armadillo-6.500.5
./configure
make
make install
cd ..
View gist:1025241
<!doctype html><!-- simplified doctype works for all previous versions of HTML as well -->
<!-- Paul Irish's technique for targeting IE, modified to only target IE6, applied to the html element instead of body -->
<!--[if lt IE 7 ]><html lang="en" class="no-js ie6"><![endif]-->
<!--[if (gt IE 6)|!(IE)]><!--><html lang="en" class="no-js"><!--<![endif]-->
<head>
<!-- simplified character encoding -->
<meta charset="utf-8">
@darcyliu
darcyliu / PriorityQueue.h
Last active Nov 6, 2018
Objective-C Priority Queue
View PriorityQueue.h
//
// PriorityQueue.h
// PriorityQueue
//
// Created by Darcy Liu on 2018/11/6.
// Copyright © 2018 Darcy Liu. All rights reserved.
//
#import <Foundation/Foundation.h>
@darcyliu
darcyliu / gist:8172847
Created Dec 29, 2013
Manual Line Breaking
View gist:8172847
CGContextRef context = UIGraphicsGetCurrentContext();
// // Flip the coordinate system
// CGContextSetTextMatrix(context, CGAffineTransformIdentity);
// CGContextTranslateCTM(context, 0, self.bounds.size.height);
// CGContextScaleCTM(context, 1.0, -1.0);
UIFont *customFont = [UIFont systemFontOfSize:20];
CTFontRef font = CTFontCreateWithName((CFStringRef)customFont.fontName, 20, NULL);
@darcyliu
darcyliu / files.go
Created Sep 17, 2018
WebDAV server in go
View files.go
// ./files -openbrowser -http=127.0.0.1:9090
package main
import (
"context"
"flag"
"net/http"
"log"
"fmt"
"net"
You can’t perform that action at this time.