Skip to content

Instantly share code, notes, and snippets.

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

杨宁 dailybird

🏠
Working from home
View GitHub Profile
@dailybird
dailybird / pom.xml
Last active March 7, 2017 15:54
Pure maven config file.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxx</groupId>
<artifactId>Xxxx</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
@dailybird
dailybird / hollow-diamond-printer.php
Last active April 1, 2017 14:31
Print a hollow diamond.
<?php
/**
* 打印空心菱形
* @param [int] $level [层数]
* @return [void]
*/
function diamondPrinter($level){
for ($index = 1; $index <= $level; $index++) {
currentLevel($index, $level);
@dailybird
dailybird / pyramid-printer.php
Last active April 1, 2017 14:30
Print a pyramid.
<?php
/**
* 打印金字塔
* @param [int] $level [层数]
* @return [void]
*/
function pyramidPrinter($level){
for ($index = 1; $index <= $level; $index++) {
for ($space = $level; $space > $index; $space--) {
@dailybird
dailybird / number_of_1_in_binary.c
Created April 7, 2017 03:28
Find the number of 1 in binary.
int upperBit(x)
{
int count = 0;
while(x)
{
count++;
x = x & (x-1);
}
return count;
}
@dailybird
dailybird / add.php
Created April 8, 2017 15:15
Simple message borad.
<?php
date_default_timezone_set('PRC');
$filename = 'messages.txt';
$username = $_POST['username'] ?? null;
$title = $_POST['title'] ?? null;
$content = $_POST['content'] ?? null;
if(!is_null($username) && !is_null($title) && !is_null($content)){
@dailybird
dailybird / nodes_to_tree.php
Created June 2, 2017 00:17
Resolve nodes to tree.
<?php
/**
* Created by PhpStorm.
* User: dailybird
* Date: 17/6/1
* Time: 下午11:57
*/
$nodes = [
@dailybird
dailybird / Combination.scala
Last active July 8, 2018 09:36
Select all combinations of N elements from the collection.
package com
import scala.collection.mutable.ArrayBuffer
object CombinationQuestion {
def main(args: Array[String]): Unit = {
val candidates = ArrayBuffer[Int](1, 3, 7, 5, 9)
val count = 3
val container = getAllCombinations(count, candidates)
@dailybird
dailybird / PatternQuestion.java
Created July 3, 2018 04:43
字符串匹配模式问题
package com;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import java.util.regex.Pattern;
public class PatternQuestion {
@dailybird
dailybird / Permutation.scala
Created July 8, 2018 09:36
Select all permutations of N elements from the collection.
package com
import scala.collection.mutable.ArrayBuffer
object PermutationQuestion {
def main(args: Array[String]): Unit = {
val candidates = ArrayBuffer[Int](1, 3, 7, 5, 9)
val count = 3
val container = getAllPermutations(count, candidates)
package com
import scala.collection.mutable.ArrayBuffer
object MagicSquare {
def main(args: Array[String]): Unit = {
val target = Array[Array[Int]](
Array[Int](4, 8, 2),