Skip to content

Instantly share code, notes, and snippets.

View nyluntu's full-sized avatar

Turo Nylund nyluntu

View GitHub Profile
@nyluntu
nyluntu / jsonEsimerkki.cs
Created February 3, 2021 18:04
Esimerkki JSON ja Newtonsoft käytöstä. Kopioitu konsoliohjelman Program.cs tiedoston sisältö tähän, joten riittää, että otat tästä vain kyseisen sisällön.
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
namespace JsonEsimerkki
{
class Program
{
static void Main(string[] args)
@nyluntu
nyluntu / github-invite-member.py
Created January 11, 2021 07:04
Github kutsuminen organisaatioon
# Require https://github.com/PyGithub/PyGithub
from github import Github
from github.NamedUser import NamedUser
# Global variables to change when script is executed.
# List of github users to invite. Separated with commas.
github_usernames_to_invite = "username1,username2,username3"
-- Sinun esimerkki
select title, description, rental_duration, rental_rate, length, rating, name as genre
from film
left join film_category on film.film_id = film_category.film_id
left join category on category.category_id = film_category.category_id
order by title;
-- Sinun esimerkki ALIAS käyttäen
select taulu1.film_id, title, description, rental_duration, rental_rate, length, rating, name as genre
from film taulu1
@nyluntu
nyluntu / checkout-submit.html
Created August 21, 2020 06:02
Lomakkeen lähettäminen kun input kentän tyyppi on image.
// Jos HTML lomake lähetetään seuraavaalla tavalla POST tyyppisenä niin
// sen mukana tulee type="image" vuoksi pari ylimääräistä tietoa.
// Koska tässä kentän nimi on "submit" niin lomakkeen mukana tulee kentät
// submit.x ja submit.y
// Kentät muodostuvat sen vuoksi, että input-elemnetin tyyppinä on "image".
<input type="image" name="submit" src="https://payment.checkout.fi/static/img/danskebank_140x75.png" title="Danske Bank" alt="Submit" class="provider-button hover01 col-xs-6" />
// Edellisen tilanteen voi korjata esimerkiksi muuttamalla hieman lomakkeen
@nyluntu
nyluntu / add_user.sh
Last active November 6, 2020 13:02
add_user.sh
#!/bin/bash
# Script will create new user account for Wordpress sites created with
# wp.sh script.
# =======================
# Define global variables
# =======================
CURRENT_DIR=$(pwd)
@nyluntu
nyluntu / csharp-mysql-injection.cs
Last active April 21, 2020 12:34
SQL injection example
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
namespace ConsoleApp1
{
@nyluntu
nyluntu / wp.sh
Last active March 9, 2024 13:19 — forked from bgallagh3r/wp.sh
Wordpress: Bash Install Script -- Downloads latest WP version, updates wp-config with user supplied DB name, username and password, creates and CHMOD's uploads dir, copies all the files into the root dir you run the script from.
#!/bin/bash
# Script to install multiple Wordpress instances into single web server.
#
# TODO: If using bitnami lamp stack, disable pagespeed module because can confuse students when js/css files are cached.
# https://docs.bitnami.com/bch/apps/wordpress/administration/use-pagespeed/
#
# REQUIREMENTS
#
# LAMP environment installed. Script is tested with Bitnami LAMP stack.
// Luodaan Person niminen luokka.
class Person
{
// Luokalla on kaksi ominaisuutta (property).
// Nimi ja ikä.
public string Name { get; set; }
public int Age { get; set; }
using System;
using System.Globalization;
namespace Ajankasittelya
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("DateTime -esimerkkejä\n\n");
@nyluntu
nyluntu / esimerkki_merkkijonolaskin.cs
Last active February 8, 2020 15:44
Esimerkki merkkijonolaskimesta
// Sinun esimerkkisi muutamilla huomioilla. Alla sitten
// toinen esimerkki lisävinkeillä.
public static int Laske(string value) {
// Tässä tarkistat tyhjän syötteen, se on oikein.
if (value == "") return 0;
// Alustat sum -muuttujan nollaksi ennen foreach
// toistolauseketta ja sekin oikein.
var sum = 0;
// Foreach yhteydessä käytät Split metodia joka pilkkoo
// annetun merkkijonon näillä haluamallasi erottimilla.