Skip to content

Instantly share code, notes, and snippets.

@lithid
lithid / logitech-bind-f13-f24.lua
Created March 14, 2019 22:16 — forked from ewauq/logitech-bind-f13-f24.lua
How to: Bind F13 to F24 keys on the G-keys (Logitech Gaming Keyboards)
-- How to use this script:
-- 1. Install the Logitech Gaming Software: http://support.logitech.com/en_us/software/lgs
-- 2. Launch it, and right click on your profile (the gear icon) and then click on "Scripts".
-- 3. Add the following code into the Script window, save it, and close it. Enjoy.
-- Now G1 is bound to F13, G2 to G14, ... G12 to F24.
function OnEvent(event, arg)
-- OutputLogMessage("event = %s, arg = %s\n", event, arg)
@lithid
lithid / gist:7932148
Created December 12, 2013 17:41
Android PreferenceActivity fix
@TargetApi(Build.VERSION_CODES.KITKAT)
private void setupSimplePreferencesScreen() {
if (!isSimplePreferences(this)) {
return;
}
if (android.os.Build.VERSION.SDK_INT >= C.SDK_19) {
if (!isValidFragment(initialFragment)) {
throw new IllegalArgumentException("Invalid fragment for this activity: "
+ initialFragment);
@lithid
lithid / gist:7932076
Created December 12, 2013 17:38
Android 4.4 PreferenceActivity fix
@TargetApi(Build.VERSION_CODES.KITKAT)
private void setupSimplePreferencesScreen() {
if (!isSimplePreferences(this)) {
return;
}
if (android.os.Build.VERSION.SDK_INT >= C.SDK_19) {
if (!isValidFragment(initialFragment)) {
throw new IllegalArgumentException("Invalid fragment for this activity: "
+ initialFragment);
for x in `find . -type f -iname "*.png"`; do convert -colorspace gray $i gray-$i; done
@lithid
lithid / gist:7327067
Last active December 27, 2015 12:39
json
public String getNetFile(String device, String url, boolean isJ) {
DefaultHttpClient defaultClient = new DefaultHttpClient();
String urlStr = url;
HttpGet httpGetRequest = new HttpGet(urlStr);
HttpResponse httpResponse = null;
try {
httpResponse = defaultClient.execute(httpGetRequest);
} catch (IllegalStateException e) {
return null;
} catch (IllegalArgumentException e) {
@lithid
lithid / Meh
Created September 1, 2013 16:12
Shown to show transparency
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
boolean result;
final int save = canvas.save(Canvas.CLIP_SAVE_FLAG);
boolean drawScrim = false;
boolean mDrawBehind = true;
if (!mDrawBehind && mCanSlide && !lp.slideable && mSlideableView != null) {
import javax.swing.JOptionPane;
public class Main {
public static void main(String[] args){
String s;
s = JOptionPane.showInputDialog("Enter batch size: ");
Recipe.request = Double.parseDouble(s);
Recipe.factor = Recipe.request / Recipe.food;
for (int i = (int) r.z; i < Recipe.sFoodList.length; i++){
Recipe.sFoodList[i] = Recipe.factor * Recipe.sFoodList[i];
//Main.java
import javax.swing.JOptionPane;
public class Main {
public static void main(String[] args){
String s;
Secondary f;
f = new Secondary();
#####
# OnClick
#####
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
new MessageTable(mContext).deleteItem(mMessageArray.get(position)[MESSAGE_ID]);
new MessageLoader().execute();
}
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mRecorder.setAudioChannels(2);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mRecorder.setAudioEncodingBitRate(96000);
mRecorder.setAudioSamplingRate(44100);