Skip to content

Instantly share code, notes, and snippets.

View PoomSmart's full-sized avatar
💻

Thatchapon Unprasert PoomSmart

💻
View GitHub Profile
@PoomSmart
PoomSmart / CheckRunning.m
Last active August 29, 2015 14:12
(iOS 7+) Check if an application is running by its bundle identifier.
BOOL isRunning(NSString *bundleID)
{
BKSSystemService *systemService = [[BKSSystemService alloc] init];
pid_t pid = [systemService pidForApplication:bundleID];
[systemService release];
return pid != 0;
}
@PoomSmart
PoomSmart / Method.h
Created March 2, 2015 07:48
A private AVCaptureStillImageOutput method
#import <AVFoundation/AVFoundation.h>
@interface AVCaptureStillImageOutput (PrivateAPI)
- (void)captureStillImageSurfaceAsynchronouslyFromConnection:(AVCaptureConnection *)connection completionHandler:(void (^)(IOSurfaceRef photoSurfaceRef, NSInteger photoSurfaceSize, IOSurfaceRef photoPreviewSurfaceRef, NSInteger photoPreviewSurfaceSize, CFDictionaryRef photoProperties))completionHandler;
@end
@PoomSmart
PoomSmart / FakePush.m
Created May 31, 2015 07:27
Fake Push Notifications for iOS 7+
#import <Foundation/Foundation.h>
// ApplePushService.framework
@interface APSMessage : NSObject
- (id)initWithTopic:(NSString *)topic userInfo:(NSDictionary *)userInfo;
@end
@interface APSIncomingMessage : APSMessage
@end
@PoomSmart
PoomSmart / ProximityLandscape.m
Created June 26, 2015 13:26
Proximity Sensor in Landscape mode.
static void setLandscapeProximityEnabled(BOOL enabled)
{
UIDevice *dev = [UIDevice currentDevice];
if (enabled) {
[dev _setExpectsFaceContactInLandscape:YES];
dev.proximityMonitoringEnabled = YES;
} else {
dev.proximityMonitoringEnabled = NO;
[dev _setExpectsFaceContactInLandscape:NO];
}
@PoomSmart
PoomSmart / FlatImageWithColor.m
Last active June 29, 2017 11:29
Reversed function of -[UIImage _flatImageWithColor:] on iOS 7+
#import <UIKit/UIKit.h>
@interface UIImage (FlatImageWithColor)
- (UIImage *)_flatImageWithColor:(UIColor *)color;
@end
@implementation UIImage (FlatImageWithColor)
- (UIImage *)_flatImageWithColor:(UIColor *)color {
UIImage *flatImage = nil;
@PoomSmart
PoomSmart / MyCourses-RecoloredCancelClassesEvents.js
Last active February 16, 2018 12:09
My Courses recolored cancel classes.
$(function() {
if (top.location.hostname === "mycourses.ict.mahidol.ac.th") {
var events = $(".calendar_event_group");
var eventLinks = $(".calendar_event_group > a");
$.each(events, function() {
var link = this.childNodes[0];
if (typeof link.text != 'undefined' && link.text.startsWith("Cancel")) {
this.style.backgroundColor = this.style.borderColor = "#ffb3b3";
var day = this.parentElement.parentElement.childNodes[0].childNodes[0].text;
$.each(eventLinks, function() {
@PoomSmart
PoomSmart / MyCourses-autoLogin.js
Last active February 16, 2018 12:09
Automatic authentication at every session timeout of MUICT My Courses.
$(function() {
if (top.location.hostname === "mycourses.ict.mahidol.ac.th") {
var username = document.getElementById("username");
var password = document.getElementById("password");
if (username != null && password != null) {
username.value = "uxx88yyy";
password.value = "password";
document.forms["login"].submit();
}
}
@PoomSmart
PoomSmart / eLearning-activeCourses.js
Last active February 17, 2018 10:07
Show only active courses in ICT eLearning website.
$(function() {
if (top.location.hostname === 'elearning.ict.mahidol.ac.th') {
var activeCourses = [ "ITCS343", "ITCS381", "ITCS323", "ITCS335", "ITLG202", "ITCS241", "ITID274" ]; // for example
var courses = $(".block_course_list > .content > .list").children();
$.each(courses, function() {
var title = $(this).text().split(" - ")[0];
if ($.inArray(title, activeCourses) == -1)
$(this).hide();
});
}
@PoomSmart
PoomSmart / MyCourses-RemovePastEvents.js
Last active February 18, 2018 12:08
Remove all no longer significant past events from the calendar.
$(function() {
if (top.location.hostname === "mycourses.ict.mahidol.ac.th") {
var _today = $(".today > .day")[0];
if (typeof _today == 'undefined')
return;
var today = parseInt(_today.innerText);
var otherDays = $(".nottoday");
$.each(otherDays, function() {
var otherDay = parseInt(this.firstChild.innerText);
if (otherDay < today) {
@PoomSmart
PoomSmart / NewMoodle-MyCourses-Advanced.css
Last active March 4, 2018 10:18
Recoloring and various interface adjustments for MUICT My Courses & E-Learning (using Stylish to apply)
/* Advanced Adjustments */
/* Star background + Transparent UI */
#page, #nav-drawer {
background-image: url("https://i.ytimg.com/vi/EZ7la-hMNuk/maxresdefault.jpg");
}
body, #page {
background-color: rgba(0,0,0,0) !important;
}