Skip to content

Instantly share code, notes, and snippets.

Avatar

Penk Chen penk

View GitHub Profile
View gist:5bc51d7305e45ebeb057
$ cat test.swift
cat test.swift
func quicksort_swift(inout a:[CInt], start:Int, end:Int) {
if (end - start < 2){
return
}
var p = a[start + (end - start)/2]
var l = start
var r = end - 1
@penk
penk / 8comic.js
Created Oct 2, 2014
8comic downloader written in casperjs
View 8comic.js
// Usage: casperjs 8comic.js http://new.comicvip.com/show/cool-1050.html
var casper = require('casper').create({
pageSettings: {
webSecurityEnabled: false
}
});
var pages, currentPage;
@penk
penk / unityscreenshot
Created Aug 21, 2014
Take screenshot from Ubuntu Touch
View unityscreenshot
#!/bin/sh
set -e
D=$(date +"%Y%m%d%H%M%S")
size=$(adb shell "fbset|sed -n -e's/^mode.*\"\([0-9]\+x[0-9]\+\)[-\"].*$/\1/p'")
adb shell mirscreencast -m /var/run/mir_socket -n 1 -f /tmp/${D}.rgba
adb pull /tmp/${D}.rgba
/opt/ImageMagick/bin/convert -depth 8 -size $size ${D}.rgba ~/Desktop/${D}.png
/bin/rm ${D}.rgba
#qlmanage -p ~/Desktop/${D}.png >& /dev/null &
@penk
penk / material-design.qml
Last active Jan 19, 2019
Material Design inspired style in QML
View material-design.qml
import QtQuick 2.0
import QtGraphicalEffects 1.0
Rectangle {
id: root
color: '#EEEEEE'
width: 960
height: 768
Item {
@penk
penk / manifest.json
Last active Aug 29, 2015
Click package manifest example
View manifest.json
{
"description": "SlateKit Shell",
"framework": "ubuntu-sdk-14.04",
"hooks": {
"slatekit-shell": {
"apparmor": "slatekit-shell.json",
"desktop": "slatekit-shell.desktop"
}
},
"maintainer": "Penk Chen <penkia@gmail.com>",
@penk
penk / main.cpp
Last active Sep 13, 2016
minimal QtWebEngine example
View main.cpp
#include <QtGui/QGuiApplication>
#include <QtQml/QQmlApplicationEngine>
#include <QtWebEngine/qtwebengineglobal.h>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QtWebEngine::initialize();
QQmlApplicationEngine appEngine;
appEngine.load(QUrl("main.qml"));
View hackeglfs.patch
diff -ru qtbase-opensource-src-5.0.0-beta1/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp qtbase-opensource-src-5.0.0-beta1-hackeglfs/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
--- qtbase-opensource-src-5.0.0-beta1/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp 2012-08-28 21:40:54.000000000 +0200
+++ qtbase-opensource-src-5.0.0-beta1-hackeglfs/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp 2012-10-06 14:50:22.748034778 +0200
@@ -130,7 +130,20 @@
QSurfaceFormat QEglFSHooks::surfaceFormatFor(const QSurfaceFormat &inputFormat) const
{
- return inputFormat;
+ QSurfaceFormat newFormat = inputFormat;
+ QByteArray depthString = qgetenv("QT_QPA_EGLFS_DEPTH");
@penk
penk / oxide.qml
Last active Jun 9, 2018
Example of Using Oxide with User Script
View oxide.qml
import QtQuick 2.0
import com.canonical.Oxide 0.1
WebView {
width: 800
height: 600
url: 'http://google.com'
context: WebContext {
userAgent: "Mozilla/5.0 (Ubuntu; Tablet) WebKit/537.21"
@penk
penk / Makefile
Last active Apr 10, 2019
SlateKit Base makefile
View Makefile
all:
for i in `find rootfs/ -type f`; do \
if [ "$$i" = "rootfs//lib64/ld-linux-x86-64.so.2" ]; then continue; \
else \
for j in `ldd $$i | cut -d \( -f1 | cut -d \> -f2 | sed 's/[ \t]*//g'`; do \
if [ ! "$$j" = "notadynamicexecutable" ] && [ ! "$$j" = "staticallylinked" ]; then \
mkdir -p rootfs/`dirname $$j`; \
cp -v -rfpL --remove-destination $$j rootfs/$$j; fi; \
done; \
fi \
@penk
penk / enable_oxide_on_eglfs.patch
Last active May 19, 2017
Enabled Oxide WebView on EGLFS QPA
View enable_oxide_on_eglfs.patch
--- oxide-qt-1.5.5.orig/qt/core/browser/oxide_qt_browser_startup.cc
+++ oxide-qt-1.5.5/qt/core/browser/oxide_qt_browser_startup.cc
@@ -155,7 +155,7 @@ void BrowserStartup::EnsureChromiumStart
if (platform == QLatin1String("xcb")) {
supported_gl_impls |= oxide::SUPPORTED_GL_IMPL_DESKTOP_GL;
supported_gl_impls |= oxide::SUPPORTED_GL_IMPL_EGL_GLES2;
- } else if (platform.startsWith("ubuntu")) {
+ } else if (platform.startsWith("ubuntu") || platform.startsWith("egl")) {
supported_gl_impls |= oxide::SUPPORTED_GL_IMPL_EGL_GLES2;
} else {