- Joined
- Jul 18, 2019
imagine swearing in your code instead of expressing your anger like an adult by dropping slurs in PRs
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Imagine not using the +NIGGER license.imagine swearing in your code instead of expressing your anger like an adult by dropping slurs in PRs
It does sound more useful than everything else out there:Finally, some useful CS research.
I think this is pretty much it. All those ancient Linux programs (including the kernel!) have very colorful language in them.The research is no good because it doesn't consider time. Consider this alternative hypothesis:
"Swearing in code was more acceptable in the 80s and any code that lasted from then long enough to make it to Github has likely been worked on and improved more than some newly written code."
//what the fuck?
in it.I also think the hypothesis is a little hasty. Perhaps the perceived hostility of a project which allows swearing and otherwise "unprofessional" communication acts as a gatekeeping mechanism against less confident developers.The research is no good because it doesn't consider time. Consider this alternative hypothesis:
"Swearing in code was more acceptable in the 80s and any code that lasted from then long enough to make it to Github has likely been worked on and improved more than some newly written code."
A better approach might have been to look at repos where a swear word was checked in sometime in the past year (and not part of a bulk migration to Git).
Every time I can use currying my soul heals a little bit.Eh? I'm not saying that C++ didn't steal a lot of pointless shit (e.g. std::accumulate). I am saying that there's not really any advantages to choosing Haskell over modern C++.
Yeah, it's impressive for an undergrad.Edit: To be fair, it is just a bachelor's thesis. Hopefully this is the beginnings of a promising academic career
vowels = ('aeiouyAEIOUY')
def splitter(i):
x = 1
for n in i:
if i[x] in vowels:
return x
else:
x += 1
name = input('Enter Name: ')
x = splitter(name)
print(f"{name}'s F{name[x:]} and S{name[x:]}.")
name = input('Enter Name: ')
name = name.lower()
name_title = name.title()
vowels = ['a', 'e', 'i', 'o', 'u', 'y', 'A', 'E', 'I', 'O', 'U', 'Y']
if name[0] in vowels:
print(name_title + '\'s ' + 'F' + name[0:] + ' and ' 'S' + name[0:])
elif name[1] in vowels:
print(name_title + '\'s ' + 'F' + name[1:] + ' and ' 'S' + name[1:])
elif name[2] in vowels:
print(name_title + '\'s ' + 'F' + name[2:] + ' and ' 'S' + name[2:])
else:
print(name_title + '\'s ' + 'F' + name[3:] + ' and ' 'S' + name[3:])
def splitter(i):
x = 1
for n in i:
if i[x] in vowels:
return x
else:
x += 1
vowels = ('aeiouyAEIOUY')
print('''
▄▀▀▄ ▄▀▄ ▄▀▀█▄ ▄▀▀█▄▄ ▄▀▀▀▀▄ ▄▀▀█▀▄ ▄▀▀█▄▄ ▄▀▀▀▀▄
█ █ ▀ █ ▐ ▄▀ ▀▄ █ ▄▀ █ █ █ █ █ █ ▐ ▄▀ █ █ █ ▐
▐ █ █ █▄▄▄█ ▐ █ █ ▐ █ ▐ █ ▐ █▄▄▄▀ ▀▄
█ █ ▄▀ █ █ █ █ █ █ █ ▀▄ █
▄▀ ▄▀ █ ▄▀ ▄▀▄▄▄▄▀ ▄▀▄▄▄▄▄▄▀ ▄▀▀▀▀▀▄ ▄▀▄▄▄▀ █▀▀▀
█ █ ▐ ▐ █ ▐ █ █ █ █ ▐ ▐
▐ ▐ ▐ ▐ ▐ ▐ ▐
''')
name = input('Enter a name: ')
name2 = input('One more name: ')
x = splitter(name)
y = splitter(name2)
print(f'''
The sign is a subtle joke.
The shop is called "{name}'s F{name[x:]} & S{name[x:]}", where f{name[x:]} and s{name[x:]} both end in the sound "-{name[x:]}", thus rhyming with the name of the owner, {name}.
The sign says that the shop was "Formerly {name2}'s", implying that the two words beginning with "F" and "S" would have ended with "-{name2[y:]}", rhyming with "{name2}".
So, when {name2} owned the shop, it would have been called "{name2}'s F{name2[y:]} and S{name2[y:]}".
''')
print('Thank you for playing!')
Well done. Here's some perhaps unwanted code review (in the comments):I've been trying to teach myself python as a first language.
# No need for parentheses here, you're assigning vowels as a string.
vowels = ('aeiouyAEIOUY')
def splitter(i):
# No need to manually keep a loop index.
x = 1
# Good style to loop directly over the input, but `n` is unused.
# There is a subtle bug: the loop will run len(i) times, but as you
# set x to 1 initially, you want it to run len(i) - 1 times. If there are
# no vowels in the input, you'll get an IndexError.
for n in i:
# Good style to use the `in` operator to check membership.
if i[x] in vowels:
return x
else:
# Here you're manually incrementing the loop index.
x += 1
name = input('Enter Name: ')
x = splitter(name)
# Good style to use f-strings and idiomatic slicing.
print(f"{name}'s F{name[x:]} and S{name[x:]}.")
def splitter_g1(string):
# Loop over integers 1 through len(i)
for index in range(1, len(string) + 1):
if string[index] in vowels:
return index
def splitter_g2(string):
# Loop over (index, character) pairs.
# enumerate takes an iterable and returns each element with its index.
# By default it starts at 0.
for index, character in enumerate(string[1:], start=1):
if character in vowels:
return index
def splitter_g3(string):
for index, character in enumerate(string[1:], start=1):
if character in vowels:
# Return the sliced string directly.
return string[index:]
enumerate
:>>> enumerate("abc")[1]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'enumerate' object is not subscriptable
>>> list(enumerate("abc"))[1]
(1, 'b')
Geranium already covered the most important topics, but I've got another couple of points that you may want to take into account for further improvement.Python:vowels = ('aeiouyAEIOUY') def splitter(i): x = 1 for n in i: if i[x] in vowels: return x else: x += 1 name = input('Enter Name: ') x = splitter(name) print(f"{name}'s F{name[x:]} and S{name[x:]}.")
the old version:
it was seriously clunky.Python:name = input('Enter Name: ') name = name.lower() name_title = name.title() vowels = ['a', 'e', 'i', 'o', 'u', 'y', 'A', 'E', 'I', 'O', 'U', 'Y'] if name[0] in vowels: print(name_title + '\'s ' + 'F' + name[0:] + ' and ' 'S' + name[0:]) elif name[1] in vowels: print(name_title + '\'s ' + 'F' + name[1:] + ' and ' 'S' + name[1:]) elif name[2] in vowels: print(name_title + '\'s ' + 'F' + name[2:] + ' and ' 'S' + name[2:]) else: print(name_title + '\'s ' + 'F' + name[3:] + ' and ' 'S' + name[3:])
# In your first attempt you used these methods
# to give the name proper capitalization
name = name.lower()
name_title = name.title()
# In case of the user inputting a name like "cHuCk" you may want
# to get this re-implemented this.
# As an added bonus this would allow you to reduce your set of
# letters to only include the lowercase vowels.
vowels = 'aeiouy'
# The indexing issue Geranium mentioned aside. Starting at index
# one means you skip the first letter of the name.
x = 1
for n in i:
if i[x] in vowels:
return x
else:
x += 1
# This works fine for names like 'Chuck' and 'Sneed', but what happens
# when the user inputs a name like 'Aron' or 'Ellen'?
Absolutely welcome, I love how simple it is with enumerate! Very insightful.Well done. Here's some perhaps unwanted code review (in the comments):
Yeah, the old code accounted for names that started with vowels but doing that when I ran the mad libs program made the output include "both end in the sound -{full uncut name}" which looked weird to me, but accounting for the first letter does make better sounding "F{eed} and S{eed}" in that case. I did just totally forget to reimplement the capitalization stuff, though. Thanks!# The indexing issue Geranium mentioned aside. Starting at index
# one means you skip the first letter of the name.
x = 1
for n in i:
if i[x] in vowels:
return x
else:
x += 1
# This works fine for names like 'Chuck' and 'Sneed', but what happens
# when the user inputs a name like 'Aron' or 'Ellen'?
[/CODE]
Set your file explorer to show the full filename.I just sperged out for like thirty minutes straight because I accidentally named a file "batch.txt.txt" instead of "batch.txt" and I couldn't figure out what was wrong with my program.
My favorite failing test cases are those where it's the test that's wrong.I just sperged out for like thirty minutes straight because I accidentally named a file "batch.txt.txt" instead of "batch.txt" and I couldn't figure out what was wrong with my program.
Way back when in university there was one Prof who published the tests he graded with along with his assignments, but wouldn't tell you the expected output. Sometimes you needed to hand in code that crashed the tests because the tests misused the program as assigned.My favorite failing test cases are those where it's the test that's wrong.
Can you elaborate more on your experience?This is actually pretty cool.
package mypackage;
import java.util.HashMap;
import java.util.Map;
public class MyRepository {
private Map<Integer, User> myRepo = new HashMap<>();
// CRUD methods
protected String getUserName(int i) {
return myRepo.get(i).getName();
}
}
}
package mypackage;
public class MyService {
private myRepo repository;
public myService(myRepo repository) {
this.repository = repository;
}
public boolean nameInUse(String name) {
boolean found = false;
for (Integer key : repository.keySet()) {
int i = Integer.parseInt(key.toString());
if (getUserName(i).equals(name)) {
found = true;
return found;
}
}
return found;
}
}
package mypackage;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class MyRepository {
private Map<Integer, User> myRepo = new HashMap<>();
// CRUD methods
protected String getUserName(int i) {
return myRepo.get(i).getName();
}
protected Set<Integer> keySet() {
return this.myRepo.keySet();
}
}
}
Yes, unless for some reason to you hate yourself and want to reinvent the wheel. This is a good opportunity to see if you can come up with a fast solution to the problem though. Always worth seeing if you can improve you initial solution.Doesn't matter if it's slow or inefficient, because in a real world situation this would be a database, right?
You're learning don't feel too bad. If you're making progress and gaining new knowledge you're on the right track. It would be worth reading about software development patterns when you get a chance, because there's more than a few.I am the biggest fucking retard the world has ever known because every 12-14 year old in their computer class figures this out right away.
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.lang.Integer;
class User {
private String name;
public User(String name){
this.name = name;
}
public String getName(){
return this.name;
}
}
class UserDemo {
private static Map<Integer, User> users = new HashMap<>();
public static void main(String[] args) {
users.put(1, new User("Mike"));
users.put(2, new User("Bob"));
users.put(3, new User("Billy"));
boolean found = false;
for (Entry<Integer, User> entry : users.entrySet()) {
if (entry.getValue().getName().equals("Bob")) {
found = true;
break;
}
}
System.out.println(found);
}
}