Skip to content

Instantly share code, notes, and snippets.

View blackmann's full-sized avatar
💭
🤟

Degreat blackmann

💭
🤟
View GitHub Profile
@textbook
textbook / ProblemSet2.py
Created November 1, 2012 13:14
MIT 6.00x - PSet 2 answers by jonrsharpe
# 1. Paying the minimum
totalPaid = 0
for month in range(12):
print("Month: {0:d}".format(month + 1))
minPayment = balance * monthlyPaymentRate
totalPaid += minPayment
print("Minimum monthly payment: {0:.2f}".format(minPayment))
balance -= minPayment
balance *= (1 + (annualInterestRate / 12))
print("Remaining balance: {0:.2f}".format(balance))
@paulund
paulund / example-wp-list-table.php
Last active May 20, 2024 05:29
An example code of using the WP_List_Table class. With Pagination.
<?php
/*
* Plugin Name: Paulund WP List Table Example
* Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area
* Plugin URI: http://www.paulund.co.uk
* Author: Paul Underwood
* Author URI: http://www.paulund.co.uk
* Version: 1.0
* License: GPL2
*/
@neilbantoc
neilbantoc / WrapContentViewPager.java
Created February 5, 2014 10:38
A simple view pager that supports wrapping of content by measuring first child and setting that as the viewpager's height.
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.View;
/*
* A simple view pager that supports wrapping of content
* by measuring first child and setting that as the viewpager's height.
*/
public class WrapContentViewPager extends ViewPager{
@blackmann
blackmann / andlog.py
Created May 24, 2014 10:38
A simple log-in app in python4android
#some simple login app
from android import Android
import time
import random
a = Android()
p=0
a.dialogCreateHorizontalProgress("Loading App")
a.dialogShow()
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active July 5, 2024 10:29
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
@mlynch
mlynch / Undo.md
Last active April 9, 2024 11:28
Undo/Redo

Undo/Redo

Undo/Redo is one of those features of an application that you almost always need to have if you are building serious GUI tools for people to do work.

The best way to look at undo/redo is two stacks of operations the user has performed:

  • The Undo stack is the "history" of what they've done
  • The redo stack is the breadcrumbs back to the initial state before they started undoing
@WrathChaos
WrathChaos / Java Country List
Created November 10, 2015 18:45
ISO Country List, How to get all country names
//Initializing Country List
final List<Country> countryList=new ArrayList<>();
public void fillCountryList(){
String[] countries = Locale.getISOCountries();
int j = 0;
// Loop each country
for(int i = 0; i < countries.length; i++) {
@lukecav
lukecav / functions.php
Created September 22, 2016 04:08
Need Woocommerce to only allow 1 product in the cart. If a product is already in the cart and another 1 is added then it should remove the previous 1
function check_if_cart_has_product( $valid, $product_id, $quantity ) {
if(!empty(WC()->cart->get_cart()) && $valid){
foreach (WC()->cart->get_cart() as $cart_item_key => $values) {
$_product = $values['data'];
if( $product_id == $_product->id ) {
unset(WC()->cart->cart_contents[$cart_item_key]);
}
}
@AndreaMinato
AndreaMinato / auth.ts
Last active June 20, 2023 00:55
Typescript Vuex Module
import axios, { AxiosRequestConfig } from "axios";
import router from "@/router"; //shortcut to src
import { Module } from "vuex";
const authModule: Module<any, any> = {
state: {
loggedIn: false,
loginError: null,
username: null
@marteinn
marteinn / _document.js
Created September 26, 2020 06:27
Next.js: How to capture and use page props in next/document
import Document, { Html, Head, Main, NextScript } from 'next/document';
class CustomDocument extends Document {
static async getInitialProps(ctx) {
let pageProps = null;
const originalRenderPage = ctx.renderPage;
ctx.renderPage = () =>
originalRenderPage({
enhanceApp: (App) => (props) => {