Skip to content

Instantly share code, notes, and snippets.

@ivoryworks
ivoryworks / get_github_issue.php
Last active October 31, 2017 23:33
get GitHub issue by PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.github.com/repos/ivoryworks/til/issues/1",
CURLOPT_HTTPHEADER => [
"User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 YaBrowser/16.3.0.7146 Yowser/2.5 Safari/537.36"
]
]);
echo curl_exec($curl);
curl_close($curl);
@ivoryworks
ivoryworks / gist:ac8577b4089476d9bab5
Created June 15, 2015 07:33
Android SharedPreferences
SharedPreferences mPreferences = getActivity().getSharedPreferences("private_pref", Context.MODE_PRIVATE);
// Read
mPreferences.getInt(PREF_VALUE, 1);
// Write
SharedPreferences.Editor editor = mPreferences.edit();
editor.putInt(PREF_VALUE, 1);
editor.apply();
from xpcom import components
viewSvc = components.classes["@activestate.com/koViewService;1"]\
.getService(components.interfaces.koIViewService)
view = viewSvc.currentView.queryInterface(components.interfaces.koIScintillaView)
sm = view.scimoz
sm.currentPos # current position in the editor
sm.text # editor text
sm.selText # the selected text
@ivoryworks
ivoryworks / Baby.php
Created April 11, 2014 00:30
Dance with ServerPush
<?php
@set_time_limit(0);
@ignore_user_abort(false);
@ini_set( 'zlib.output_compression', 'off' );
header('Cache-Control: no-cache');
header('Pragma: no-cache');
header("Content-Type: multipart/x-mixed-replace;boundary=END",true);
print "--END\n";
$index = 0;
<?php
@set_time_limit(0);
@ignore_user_abort(false);
@ini_set( 'zlib.output_compression', 'off' );
header('Cache-Control: no-cache');
header('Pragma: no-cache');
header("Content-Type: multipart/x-mixed-replace;boundary=END",true);
print "--END\n";
<?php
// Load
$lines = file('st.txt');
$BASE = array();
for ($i = 0; $i < count($lines); $i++) {
$word = trim($line);
$BASE[$i]['word'] = $word;
$BASE[$i]['prefix'] = mb_substr($word, 0, 1);
$BASE[$i]['suffix'] = mb_substr($word, strlen($word)-1, 1);
$BASE[$i]['isUse'] = false;
private static class Cat extends Sprite {
public final PhysicsHandler mPhysicsHandler;
public Cat(final float pX, final float pY,
final TextureRegion pTextureRegion,
final VertexBufferObjectManager pVertexBufferObjectManager) {
super(pX, pY, pTextureRegion, pVertexBufferObjectManager);
mPhysicsHandler = new PhysicsHandler(this);
registerUpdateHandler(mPhysicsHandler);
mPhysicsHandler.setVelocity(DEMO_VELOCITY, DEMO_VELOCITY);
package com.ivoryworks.android.andenginegarage.sprite;
import org.andengine.engine.camera.Camera;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.scene.background.Background;
import org.andengine.entity.sprite.Sprite;
import org.andengine.entity.util.FPSLogger;
package com.example.Blank;
import org.andengine.engine.camera.Camera;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.scene.background.Background;
import org.andengine.entity.util.FPSLogger;
import org.andengine.ui.activity.SimpleBaseGameActivity;