Skip to content

Instantly share code, notes, and snippets.

public class TempConverterMain extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_temp_converter_main);
// I'd prefer not to have to declare these twice, so I can use them in my subclass below
#include "commctrl.h"
#define SUBMIT_ANSWER 0x01
#define EDIT_ANSWER 0x02
#pragma comment(linker,"\"/manifestdependency:type='win32' \
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
// ...
// inside the WM_ACTIVATE case
bigFont = CreateFont(90, 20, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0, 0, TEXT("Courier New"));
mediumFont = CreateFont(90, 20, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0, 0, TEXT("Segoe UI"));
SendMessage(g_hEdit_Answer, WM_SETFONT, (WPARAM)bigFont, 0);
SendMessage(g_hSubmit_Answer, WM_SETFONT, (WPARAM)mediumFont, 0);
if (SendMessage(g_hLabel, WM_SETTEXT, 0, (LPARAM)L"Guess a number between 0 and 99."))
bool x = TRUE;
else
bool x = FALSE;
}
// snip
switch (message)
{
int theRandomNumber = getRandomNumber();
int currentGuess = 0;
int tries = 0;
std::string triesString = "Tries: " + tries;
SendMessage(g_hEdit_Answer, EM_SETCUEBANNER, 0, (LPARAM)L"Enter guess..");
SendMessage(g_hLabelEdit_Result, WM_SETTEXT, 0, (LPARAM)L"Guess a number between 0 and 99.");
SendMessage(g_hLabelEdit_Info, WM_SETTEXT, 0, (LPARAM)triesString.c_str());
void startGame() {
int theRandomNumber = 90; /* getRandomNumber(); */
// snip
}
// startGame() is called when the button is pressed, followed by checkNumber()
void checkNumber() {
wchar_t currentGuessBuffer[4] = { 4 };
SendMessage(g_hEdit_Answer, EM_GETLINE, NULL, (LPARAM)currentGuessBuffer);
SendMessage(g_hLabelInfo2, WM_SETTEXT, 0, (LPARAM)currentGuessBuffer);
void convertBuffToInt(wchar_t buffer[]) {
int temp = 0;
for (int i = 0; i < sizeof(buffer) / sizeof(buffer[0]); i++) {
if (buffer[i] == '\0') {
break;
}
temp = temp * 10 + ((int)buffer[i] - 48);
}
@Seth-Johnson
Seth-Johnson / gist:9072d70b61f3b7da74d6
Created December 28, 2014 23:38
Gtk testing stuff
from gi.repository import Gtk
win = None
class MyFirstWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="First Class")
self.button1 = Gtk.Button(label="Click me. Quick!")
self.button1.connect("clicked", self.on_button_clicked)

Keybase proof

I hereby claim:

  • I am seth-johnson on github.
  • I am sethj (https://keybase.io/sethj) on keybase.
  • I have a public key whose fingerprint is 27DD B98D D6CE 4618 6DAD 97C0 9B4A 13D0 002A 515A

To claim this, I am signing this object:

(function(){
var separateThousands = function(n) {
var s = String(n);
s = s.replace(/[1-9][0-9]*/, function(match) {
var r = "";
for (var i = 0; i < match.length; i++) {
r = match[match.length - 1 - i] + r;
if (i % 3 == 2 && i < match.length - 1) {
r = "," + r;
}