Skip to content

Instantly share code, notes, and snippets.

@dj-amadeous
dj-amadeous / xml_activity_main
Created April 21, 2019 04:19
image not showing when background transparrent
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:id="@+id/imageView6"
@dj-amadeous
dj-amadeous / calloc.c
Created October 30, 2018 08:29
an example of calloc from the cpp reference documentation
int calloc_example(){
int* p1 = calloc(4, sizeof(int)); // an array of 4 integers
int* p2 = calloc(1, sizeof(int[4])); // same thing, but mixed up where the size and space goes. (it doesn't matter)
int* p3 = calloc(4, sizeof *p3); // same thing but without using int, instead using the dereferenced version of p3
if(p2) {
for(int n = 0; n < 4; n++) // printing array
printf("p2[%d] == %d\n", n, p2[n]);
}
@dj-amadeous
dj-amadeous / size.c
Created October 30, 2018 01:37
example of using fgets to get integer input to avoid scanf
int getSize(){
int numEl;
char term[3];
printf("Enter size of Array:");
fgets(term, 6, stdin);
numEl = strtol(term, NULL, 10);
return numEl;
}
evans-MBP:chapter19 evancornish$ node 03_using_generic_flow_control.js
starting...
printing args first time
[]
undefined
undefined
Iteration: 1
[]
printing args first time
[ null, 13 ]
var fs = require('fs');
function cascade(callbacks, callback) {
// clone the array
var functions = callbacks.slice(0);
function processNext(err) {
if (err) {
@dj-amadeous
dj-amadeous / boomerang.js
Created June 3, 2018 21:24
an example of callback hell
var fs = require('fs');
function append_some_a_to_b(callback) {
fs.open(__dirname + '/a.txt', 'r', function(err, aFd) {
if (err) {
return callback(err);
}
var buffer = new Buffer(10);
@dj-amadeous
dj-amadeous / main.cpp
Created October 11, 2017 03:08
what is the point on line 8 of "edu.uta.cse1325.turtle1"
#include "mainwin.h"
#include <gtkmm/application.h>
#include <gtkmm/window.h>
int main(int argc, char** argv)
{
// Create the application
auto app = Gtk::Application::create(argc, argv, "edu.uta.cse1325.turtle1");
// Instance a window
@dj-amadeous
dj-amadeous / main_window.cpp
Created October 11, 2017 02:28
line 11, add is part of gtkmm but no namespace or method call on an object?
Main_window::Main_window() {
// /////////////////
// G U I S E T U P
// /////////////////
set_default_size(400, 200);
// Put a vertical box container as the Window contents
Gtk::Box *vbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 0));
@dj-amadeous
dj-amadeous / dialogs.h
Created October 3, 2017 03:30
my dialogs class
#ifndef DIALOGS_H
#define DIALOGS_H
#include <iostream>
#include <gtkmm.h>
#include <string>
class Dialogs
{
@dj-amadeous
dj-amadeous / puzzle.h
Created September 12, 2017 16:40
class header for my puzzle class
class puzzle
{
public:
puzzle(std::string solution);
//method for guesses
bool guess(char);
void printsol();
//printing out bool values for testing
bool getGuesses(int);
//method to test the solution is valid