Skip to content

Instantly share code, notes, and snippets.

@duydb2
duydb2 / Install Cloud9 on local or remote computer, server, or raspberry pi This gist will help you install Cloud9 on your local or remote computer, server, or even your raspberry pi. Many people are having issues at the time of this Gist's creation.
Complete installation process:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y python-software-properties python make build-essential g++ curl libssl-dev apache2-utils git libxml2-dev
sudo apt-get update
sudo apt-get upgrade
cd ~
mkdir git
cd ~/git
@duydb2
duydb2 / proxy.js
Created May 1, 2018 17:21 — forked from gouroujo/proxy.js
Proxy on /api for express app using node http-proxy
import { createProxyServer } from 'http-proxy';
import url from 'url';
import _ from 'lodash';
module.exports = app => {
const proxy = createProxyServer();
app.all('/api/v1/*', (req, res) => {
const path = _.drop(req.url.split('/'), 3);
proxy.proxyRequest(req, res, {
target: url.resolve('YOUR URL', path.join('/')),
@duydb2
duydb2 / ping.py
Created January 23, 2017 09:22 — forked from pklaus/ping.py
A pure python ping implementation using raw socket.
#!/usr/bin/env python2
"""
Other Repositories of python-ping
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* https://github.com/l4m3rx/python-ping supports Python2 and Python3
* https://bitbucket.org/delroth/python-ping
@duydb2
duydb2 / sendeth.py
Created January 23, 2017 09:22 — forked from cslarsen/sendeth.py
One way of sending raw Ethernet packets in Python
"""Demonstrates how to construct and send raw Ethernet packets on the
network.
You probably need root privs to be able to bind to the network interface,
e.g.:
$ sudo python sendeth.py
"""
from socket import *
@duydb2
duydb2 / GoogleTest.cmake
Created December 22, 2016 05:41 — forked from dnmiller/GoogleTest.cmake
CMake custom target for adding Python tests and GoogleTest unit tests to compiled libraries. Tests are run via nose.
# Custom cmake target for creating a target using gtest for unit testing.
function(add_gtest_target TARGET_NAME TARGET_LIB)
set(TEST_EXEC _${TARGET_LIB}_test)
# Build the test executable.
add_executable(${TEST_EXEC} ${ARGN})
target_link_libraries(${TEST_EXEC} ${TARGET_LIB})
# gtest was not found with a find_package command and must be linked to
@duydb2
duydb2 / bluetooth-enabled.m
Created December 1, 2016 07:36 — forked from chrismaddern/bluetooth-enabled.m
Determine whether bluetooth is enabled on iOS
- (void)startBluetoothStatusMonitoring {
// Horrible formatting, but nicer for blog-width!
self.bluetoothManager = [[CBCentralManager alloc]
initWithDelegate:self
queue:dispatch_get_main_queue()
options:@{CBCentralManagerOptionShowPowerAlertKey: @(NO)}];
}
#pragma mark - CBCentralManagerDelegate
@duydb2
duydb2 / fix.sh
Created November 16, 2016 03:19
fix ideviceinstaller Could not connect to lockdownd. Exiting.
brew uninstall ideviceinstaller
brew uninstall libimobiledevice
brew install --HEAD libimobiledevice
brew link --overwrite libimobiledevice
brew install ideviceinstaller
brew link --overwrite ideviceinstaller
@duydb2
duydb2 / protectedMethods.m
Created November 14, 2016 10:41 — forked from BenedictC/protectedMethods.m
Faking Protected Methods in Objective-C
//
// main.m
// Protected
//
// Created by Benedict Cohen on 07/03/2012.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
//
// Unlike other object orientated languages Objective-C does not
// provide a mechanism for scoping methods as public, protected or private.
@duydb2
duydb2 / bluetooth-audio.m
Created November 14, 2016 03:18 — forked from kharmabum/bluetooth-audio.m
Bluetooth audio session set up
// App delegate
#import <AVFoundation/AVFoundation.h>// place in .h
// applicationDidFinishLaunchingWithOptions
// [self prepareAudioSession];
- (BOOL)prepareAudioSession {
// deactivate session
@duydb2
duydb2 / compile-objc.sh
Created October 21, 2016 11:13 — forked from sindresorhus/compile-objc.sh
Compile Objective-C on the command-line with clang
# -fobjc-arc: enables ARC
# -fmodules: enables modules so you can import with `@import AppKit;`
# -mmacosx-version-min=10.6: support older OS X versions, this might increase the binary size
clang main.m -fobjc-arc -fmodules -mmacosx-version-min=10.6 -o main