Skip to content

Instantly share code, notes, and snippets.

View danleyb2's full-sized avatar
:octocat:
...

Nyaundi Brian danleyb2

:octocat:
...
View GitHub Profile
//this is a simple script that takes in two value, the product and sum of two numbers in a
//quadratic equation and tries to solve for the values to be used in solving the equation
function PpSp(p,s){
big:for (var i=1;i<p;i++){
for(var j=1;j<p;j++){
if ((i*j)==p){
if ((i+j)==s){
// System.out.println("I got it. The numbers are "+i+" and "+j);
@danleyb2
danleyb2 / solveQE.java
Last active August 29, 2015 14:16
a simple command line program to solve quadratic equations
package main;
import java.util.Scanner;
public class solverQE {
static double A, B, C;
public static void main(String[] args) {
import java.awt.Component;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import javax.swing.*;
public class Board extends JPanel implements ActionListener, Runnable {
Dude p;
@danleyb2
danleyb2 / askBoolean.java
Last active August 29, 2015 14:20
ask a question that only accept a YES or NO answer
public static String askQuestion(String question){
Scanner ans=new Scanner(System.in);
String response;
do{
System.out.println(question);
response=ans.next();
}while(!response.equalsIgnoreCase("yes")||!response.equalsIgnoreCase("no"));
return response;
#!/usr/bin/env python
import pyglet
mp3 = "test.mp3"
source = pyglet.media.load(mp3)
player = pyglet.media.Player()
player.queue(source)
player.play()
import java.awt.*;
import javax.swing.ImageIcon;
public class Enemy {
Image img;
int x, y;
boolean isAlive = true;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import javax.swing.ImageIcon;
public class Dude {
int x, dx, y,nx,nx2,left, dy;
Image still,jump,reverse;
import java.awt.*;
import javax.swing.ImageIcon;
public class Bullet {
int x,y;
Image img;
boolean visible;
var color = '#'+(Math.random()*0xFFFFFF<<0).toString(16);
function changeBackground(color) {
document.body.style.background = color;
}
@danleyb2
danleyb2 / 0_reuse_code.js
Last active August 29, 2015 14:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console