Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
...

Nyaundi Brian danleyb2

:octocat:
...
View GitHub Profile
@danleyb2
danleyb2 / solveQE.java
Last active Aug 29, 2015
a simple command line program to solve quadratic equations
View solveQE.java
package main;
import java.util.Scanner;
public class solverQE {
static double A, B, C;
public static void main(String[] args) {
View mYscript.js
//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);
View Board.java
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 Aug 29, 2015
ask a question that only accept a YES or NO answer
View askBoolean.java
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;
View pyglet-audio.py
#!/usr/bin/env python
import pyglet
mp3 = "test.mp3"
source = pyglet.media.load(mp3)
player = pyglet.media.Player()
player.queue(source)
player.play()
View Enemy.java
import java.awt.*;
import javax.swing.ImageIcon;
public class Enemy {
Image img;
int x, y;
boolean isAlive = true;
View dude.java
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;
View Bullets.java
import java.awt.*;
import javax.swing.ImageIcon;
public class Bullet {
int x,y;
Image img;
boolean visible;
View color.js
var color = '#'+(Math.random()*0xFFFFFF<<0).toString(16);
function changeBackground(color) {
document.body.style.background = color;
}
@danleyb2
danleyb2 / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console