Skip to content

Instantly share code, notes, and snippets.

@b8jdkal
b8jdkal / searchable_entity.php
Created November 24, 2016 08:32
make entity searchable, extension for entity repository
<?php
namespace Test\Bundle\Entity;
use Doctrine\ORM\EntityRepository;
/**
* AdvBaseRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
@b8jdkal
b8jdkal / wp-query-ref.php
Created July 25, 2017 03:13 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
@b8jdkal
b8jdkal / read.c
Created September 20, 2017 10:16
用c来读文件, 运行./testcread然后输入文件名
#include <stdio.h>
#include <stdlib.h>
int main()
{
int d = 0;
char ch, file_name[525];
FILE *fp;
printf("Enter the name of file you wish to see\n");
@b8jdkal
b8jdkal / file.js
Created September 20, 2017 10:17
用nodejs来读文件 node file.js 文件名
var fs = require('fs');
var path = process.argv.slice(2).pop();
var start = new Date();
var readStream = fs.createReadStream(path);
readStream
.on('data', function (chunk) {
})
.on('end', function () {
var end = new Date();
@b8jdkal
b8jdkal / 2memory.c
Created September 21, 2017 09:54
read to memory
/*
A demo of reading the entire contents of a file. Other than
"echoing" the contents of the file to the console this program
does do anything useful.
The program assumes we have a file called test.dat in the same
directory as the executible.
M. Kesson
4.12.03
@b8jdkal
b8jdkal / read.go
Created September 21, 2017 10:47
read file using go
/*
from https://stackoverflow.com/questions/14514201/how-to-read-a-binary-file-in-go
*/
package main
import (
"fmt"
"io"
"os"
)
@b8jdkal
b8jdkal / static.js
Last active October 6, 2017 10:47
一个简单的文件服务器
const express = require('express')
const app = express()
app.use(express.static('./folder'));
app.listen(3000, function () {
console.log('Example app listening on port 3000!')
})
@b8jdkal
b8jdkal / server.js
Created October 6, 2017 10:48
一个简单的测试服务器
var http = require("http");
var server = http.createServer(function(request, response) {
console.log(request.headers);
console.log(request.method);
console.log(request.url);
var body = [];
request.on('data', function(chunk) {
body.push(chunk);
}).on('end', function() {
@b8jdkal
b8jdkal / searchPrimes.js
Last active October 21, 2017 12:04
搜索素数
var primes = [];
for(var i = 3; i < 10; i++){
var noFactor = true;
//console.log('i = ', i);
for(var factor = 2; factor < i; factor++){
//console.log('factor = ', factor);
// check whether it has factor
if(i % factor == 0){
noFactor = false;
break;
@b8jdkal
b8jdkal / gist:d9861a4d02a5df99b0c6bb767ca57df9
Last active March 15, 2018 16:18
Building Electron with
sudo npm install node-gyp -g
sudo npm install sqlite3
cd node_modules/sqlite3
sudo node-gyp configure --module_name=node_sqlite3 --module_path=../lib/binding/electron-v1.8-darwin-x64
sudo node-gyp rebuild --target=1.8.1 --arch=x64 --target_platform=darwin --dist-url=https://atom.io/download/atom-shell --module_name=node_sqlite3 --module_path=../lib/binding/electron-v1.8-darwin-x64
#ref
#https://stackoverflow.com/questions/38716594/electron-app-cant-find-sqlite3-module
#https://stackoverflow.com/questions/32406397/using-nodejs-plugins-in-elelectron/32415283
#https://github.com/electron/electron/blob/master/docs/tutorial/using-native-node-modules.md