« first day (2269 days earlier)      last day (2566 days later) » 

5:00 PM
Hey all =) Anyone around?
 
Last message 3m ago, so that's a yes :)
 
Greetings (again)!
 
anyone here?
 
no
 
:(
 
5:08 PM
:(
 
Reading about the Turkey referendum right now, sounds terrible
 
Has there ever been a good referendum?
 
@Mendeleev scroll up, you'll think you're seeing the us elections
 
@betseg up? I'm at the top of the Wikipedia page
 
Remember when the brits had one? Pepperidge Farm Remembers.
 
5:09 PM
@Mendeleev in this page
 
oh
wat
 
@Mendeleev can I add reCAPTCHA to POST stories/stories
 
@Downgoat how?
 
like through form submission
but that'll require ruby to take data from form instead of JSON
 
I was thinking about posting a challenge named "Thunderstruck"
 
5:11 PM
Just turn back on the XSS protection and use native Rails layouts/forms instead of AJAX/whatever
 
@LuisMendo Hi
 
Then you can add reCAPTCHA
Also, Rails really doesn't like being hosted in a subdirectory. Try a subdomain.
 
but it is working?
 
not really, none of the pages work
Try using stories.vihan.org
 
oh I see
 
5:20 PM
1
Q: Fermat's factorization helper

ArnauldWe'd like to factorize a semiprime N. The goal of this challenge is to find two small integers u and v such that u*v*N can be trivially factorized with Fermat's method, thus allowing to easily deduct the factors of N. The task Given a semiprime N and a positive integer k, we define x and y as: ...

 
@Mendeleev how to I make rails stop doing subdirectory?
 
Electoral Council of Turkey is live, saying results from Anatolian Agency is untrue
wtf is happening
 
@Downgoat Stop rewriting it
 
@Mendeleev ? even if I directly do a request to the server it 404s
$ curl -D - 127.0.0.1:3001
HTTP/1.1 404 Not Found
 
You're firewalling it?
 
5:27 PM
nope, it just 404s there
the JSON endpoints work
$ curl -D - 127.0.0.1:3001/stories.json
HTTP/1.1 200 OK
 
OK, try just /stories
Oh, I remember
it's becauseof the config you put in the environments files
remove those
 
$ curl -sD - 127.0.0.1:3001/stories | head -n1
HTTP/1.1 404 Not Found
oh, ok
>_> I need to stop messing with server on live production server
$ curl -sD - 127.0.0.1:3001 | head -n1
HTTP/1.1 404 Not Found
$ curl -sD - 127.0.0.1:3001/stories | head -n1
HTTP/1.1 404 Not Found
I made changes to file and restarted server. is there anything else I might need to do
 
@Lembik Hey! Current specs are quite sensible I think :-)
 
@Downgoat What's the actual header sent?
 
@LuisMendo Great. Your answer is more awesome than I can internalize currently :)
how do you do the multiset intersection ?
 
5:33 PM
@Downgoat Don;t know... try starting from -e development
 
@mınxomaτ these:
> GET /stories HTTP/1.1
> User-Agent: curl/7.38.0
> Host: 127.0.0.1:3001
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Content-Type: text/html; charset=utf-8
< X-Request-Id: 3a23ba0a-3fd5-4089-95c3-2e9c40100e62
< X-Runtime: 0.040084
< Content-Length: 1564
 
@LuisMendo you sort and then count the differences? Do you do this for all the multisets in the current part each time you get a new multiset?
 
@Lembik The multisets are rows of a matrix. I compute consecutive differences along each column. If there's a nonzero difference that column doesn't "qualify". There can be at most 1 such column.
 
@LuisMendo and you have sorted them to cope with ordering?
so the matrix grows as the number of multisets in a part grows?
 
@Lembik Each time a get a new multiset I concatenate with current part and test. If the test is negative, current multiset is pulled off to start a part on its own
@Lembik Yes, the rows are initially sorted
 
5:36 PM
it's a pretty awesome to a not particularly trivial question
 
Yes, the matrix grows as new multisets are succesfully added to the part
 
I hope I get some more answers in other languages too
one mystery is if there is a formula for the number of parts
 
TBH, I wasn't sure if testing along each column was enough. I mean, can the same element appear on different columns in different multisets? But from the test cases it seems to be enough to test along columns
I guess the sorting guarantees that, but I'm not sure how
 
@LuisMendo yes.. I mean you can have (1,1,1) and (1,2,3)
 
Well, that case is not problematic, because the common 1 is in the same col
 
5:39 PM
1,2,3,4 and 2,3,4,5 ?
those will both exist
 
Yes, that case would be problematic. But somehow those two multisets never need to be tested together
(at least in the test cases)
 
right... the trick is that they are listed in sorted order
so the question is why is there never a problem for your code....
 
Exactly. The sorted property is no doubt involved in that. Not sure how, or if that's actually true
 
you may just have been lucky :) I am not sure
 
Totally agree :-D
I wouldn't rely on this method in a real application, without a proof that it works
Maybe some more test cases?
 
5:43 PM
yes.. of course I have to make the test cases :)
 
-1
Q: Multiple of 84 that consist only of 6 and 7

Alan Tampublic class Test { public static void main(String[] args){ int number = 84; int factor = 4; boolean state = true; for (factor = 4; ; factor += 5){ String multiply = number * factor + ""; for(int index = 0; index <=multiply.length() - 1; ++in...

 
ARe the rules here coherent, and does the challenge make sense? codegolf.meta.stackexchange.com/a/12113/33193
 
@Mendeleev does rails automatically process sass files? :O
 
Yes
 
:O this is amazing
no need to wait 15 minutes for npm run build
 
5:49 PM
It also automatically processes CoffeeScript
 
eeww coffeescript
 
0
A: Sandbox for Proposed Challenges

N3buchadnezzarYou've been Thunderstruck! Background A "fun" drinking game is based on the classical hard rock song by AC/CD: Thunderstruck. The Thunderstruck drinking game starts when the song starts. When the word "thunder" is heard, the first person starts drinking, not stopping until the word "thunder" is...

 
@Lembik I have a added a disclaimer in the answer
 
@LuisMendo I suspect the sorted order saves you having thought about it a little
but we shall see
 
Yes, if that's true, the sorted order is at the heart of the reason
 
6:04 PM
Give me a random letter
 
@quartata is tf2 supposed to be eating 8GB of disk space
 
Yes
 
@Midnightas a="abcdefghijklmnopqrstuvwxyz";a[Math.floor(Math.random()*26)]
 
@KritixiLithos Well, uhhh. Sure, that works lol
 
0
Q: Build a date shift cipher, which skips punctuation and whitespace and uses a modular lowercase then uppercase alphabet

jacksy_jillYour program must: - Take a date as input, in 8 figure format (day or month, month or day, year) - Take input of a string of any length. - Shift the first letter by the first figure of the date, the next letter by the next number, etc. Start again at the first number after 8 alphabetic characters...

 
6:19 PM
@betseg Yes
 
@NewMainPosts close needed, no objective winning criterion
and unclear fwiw but ^ more
 
1
Q: The Pedant's Cosine

Silvio MayoloMy boss just told me to write a cosine function. Being a good math geek, my mind immediately conjured the appropriate Taylor Series. cos(x) = 1 / 1! - x^2 / 2! + x^4 / 4! - x^6 / 6! + ... + (-1)^k x^(2k) / (2k)! + ... However, my boss is very picky. He would like to be able to specify exactly ...

 
@Mendeleev /stories/:id works but /stories does not display list...
 
6:36 PM
If anyone who is fluent in Mathematica is here right now, is there anything that you can see to improve this solution? codegolf.stackexchange.com/a/116708/36670
 
@GamrCorps You could make it an anonymous function.
Normal[Series[Cos[k],{k,0,2#2}]]/.{k->#}&
Might need parantheses arround the entire thing except the &
You can then call it as a normal function.
Cos[k] can be Cos@k
Likewise, Normal[ ... ] can be Normal@...
 
Wow, I didn't know about those! Thanks!
 
If you want to give it a name (for testing) you can do f=LAMBDA and then call f normally.
@Downgoat Only 8? I'm getting 18GB.
 
I mean server
 
oic
@GamrCorps About anonymous functions: They have to end with &, and the first argument is #, the second argument is #2, the third is #3, etc. There are builtin functions (and you can write your own) that take a function name/lambda as a parameter, for example a map function might look like map[list_, function_] := function /@ list
(Though obviously, map is already built in as /@, so this example isn't useful)
 
6:49 PM
Oh, I was wondering how that worked... Ok that makes sense
 
@GamrCorps Your avatar looks very similar to KritixiLithos.
 
@GamrCorps Question: what does 2#2-2 mean
 
I almost confused you two
 
@Downgoat 2 * ARGV[2] - 2
 
ARGV = lambda args?
 
user165474
6:55 PM
 
Ye
 
what about /.{k->#}&
 
@Downgoat .replaceAll(k,ARGV[1], the & signifies that the entire thing is a lambda.
(ARGV is 1-indexed)
 
@Mendeleev I added stories.api.vihan.org but still no work :(
@Pavel so {k->#} is replace part right?
 
Yeah
/. is an alias for the ReplaceAll function
 
6:58 PM
huh, cool
 
Btw, @GamrCorps if the first part of your replace rule is a variable, you don't need the curly braces. (If it's a number, it will parse as division, decimal point)
Normal@Series[Cos@k, {k, 0, 2 #2 - 2}] /. k -> # &
(Mathematica inserts spaces automatically in the interactive notebook for readability.)
 
would 121 /. { 1->3 }output 323 in mathematica?
 
No
 
:(
 
But you can do Cos[x]/.Cos->Sin to get Sin[x]
 
7:11 PM
Hey just a reminder, I have 100 rep bounty that expires in two days. And only one person has made an answer that is eligible. If you want to get 100 rep for programming in python give it a shot. If I see a particularly nice answer I might even sweeten the pot further.
 
user165474
@WheatWizard So by the first stipulation, you mean that any program with a Levenstein distance of 1 from my program should cause it to behave differently?
 
user165474
Oh wait, does adding bytes matter?
 
@HyperNeutrino No not quite
 
user165474
I guess not because otherwise you could add an extra semicolon somewhere and make it fail
 
No character should be deletable, and each character should have a character that switching to breaks the program
 
user165474
7:14 PM
Question: Isn't the Python answer invalid? If I swap a semicolon for a newline, it will still work the same way.
 
-2
Q: Clebsch-Gordan coefficients

S.G.Write the shortest code to calculate the Clebsch-Gordan coefficients for the expansion of the state with spin S and spin projection m into states with spins S1 and S2.

 
@HyperNeutrino First of all no that actually doesn't work and second of all I stipulate that ther must be a switch that breaks it not that every switch breaks it
btw thanks for the pastebin
 
user165474
@WheatWizard Oh, sorry, misinterpreted. And I just realized that I misinterpreted the entire challenge >_>
 
user165474
Did the same thing as this guy >_>
 
user165474
How does one compile Python code into a .pyc?
 
7:22 PM
^ we discussed it in that chat
 
user165474
Thanks.
 
For goats sake why we keep messing up referendums
 
7:43 PM
0
Q: The circle of 3 points

Yam BThe task Quite simple: given three user inputs of points A, B and C (each point requiring a user input of an x and y coordinate); find the origin of a circle that goes through all three points and print the result. Rules It must work for any input. Print the x and y coordinate of the circle's...

 
rip democracy
 
user165474
rip :/ voting closed?
 
@DJMcMayhem o_O I was about to start talking about how our avatars are very different, but ... the resemblance is uncanny (but we are not socks of each other :P)
 
@HyperNeutrino voting closed 6 hours ago, counting just recently finished
 
user165474
Results?
 
7:50 PM
50.4 want the change
 
user165474
Oh :/
 
What's the change?
 
user165474
@KritixiLithos Erdogan is becoming dictator (Turkey)
 
i should remove that userscript...
 
user165474
Which one ?
 
7:53 PM
caret reply
 
user165474
Oh.
 
user165474
I find it quite convenient
 
i wanted to caret you, replied you instead
 
That referendum is the final thing, or is there going to be another because the percentages are very close the each other?
 
@KritixiLithos Especially since the avatars are very small on my phone
 
7:58 PM
@KritixiLithos the biggest opposition party objected for 60% of the ballot boxes
supreme electoral counsel allowed ballots without a seal to be counted :/
 
user165474
@betseg That sounds shady... :/ I feel like some of the ballots are placed there to force the number over...
 
It's on top stories on bbc
 
@HyperNeutrino literally i can print my own ballots and put them
 
user165474
@betseg So wait, somebody could have just printed a million ballots against it and stopped the dictatorship?
 
nah, certain number of ballots per box
 
user165474
8:04 PM
Oh.
 
user165474
Organize something across the country?
 
if erdogan supporters cought yes votes to be manipulated they'd let it happen. if they cought no they'd call the police
 
user165474
Yeah, definitely. Not a good place regardless >_> sorry about that
 
user165474
 
8:26 PM
a friend shared a Stalin quote, and it fits with the referandum:
> The people who cast the votes decide nothing. The people who count the votes decide everything.
 
user165474
@betseg That is unfortunately true...
 
> I thank the Election Counsel. -Erdogan
 
8:42 PM
0
A: Sandbox for Proposed Challenges

flawrCompute the Fermat-Torricelli Point code-golfgeometrymath The Fermat-Torricelli point is the point P of a triangle that minimizes the sum of its distances to the three vertices A,B,C i.e. P = argmin |A-P| + |B-P| + |C-P| You might know this definition from the gemetric median. But unlike the...

 
@Downgoat Logs?
 
@Mendeleev here's the one for by_school?school_id=
I, [2017-04-16T20:45:07.673431 #678]  INFO -- : [dffdb3f4-383c-4e94-b528-d28675eb04fc] Started GET "/stories/by_school?school_id=2" for 73.93.155.130 at 2017-04-16 20:45:07 +0000
I, [2017-04-16T20:45:07.676496 #678]  INFO -- : [dffdb3f4-383c-4e94-b528-d28675eb04fc] Processing by StoriesController#by_school as HTML
I, [2017-04-16T20:45:07.676572 #678]  INFO -- : [dffdb3f4-383c-4e94-b528-d28675eb04fc]   Parameters: {"school_id"=>"2"}
I, [2017-04-16T20:45:07.678359 #678]  INFO -- : [dffdb3f4-383c-4e94-b528-d28675eb04fc] Completed 406 Not Acceptable in 2ms (ActiveRecord: 0.0ms)
 
Huh.
By school only supports JSON.
 
ah ok, /stories gives this:
[001efef2-9a44-4ccf-8552-2408925674f0] app/views/stories/index.html.erb:17:in `_app_views_stories_index_html_erb__2806418834673018404_69916880935700'
I, [2017-04-16T20:46:04.171255 #678]  INFO -- : [09ead402-0bcf-4c15-9ea8-5b49c06a481a] Started GET "/stories" for 73.93.155.130 at 2017-04-16 20:46:04 +0000
I, [2017-04-16T20:46:04.172434 #678]  INFO -- : [09ead402-0bcf-4c15-9ea8-5b49c06a481a] Processing by StoriesController#index as HTML
I, [2017-04-16T20:46:04.173669 #678]  INFO -- : [09ead402-0bcf-4c15-9ea8-5b49c06a481a]   Rendering stories/index.html.erb within layouts/application
 
Try using by_school.json?whatever
This is giving errors because you have a story for school 1, but the school itself doesn't exist. Try recreating the database.
Delete it and rails db:schema:load
 
8:48 PM
@Mendeleev would this clear existing entries?
 
@Downgoat Yes.
Do you need them?
 
yeah
 
If so, I can think of a solution.
Shut down the app. Become the user that runs the Rails database. cd to the folder that contains it. type in sqlite3 production.sqlite3
Type in DELETE FROM stories WHERE school_id = 1;
type ctrl+d
try reloading
@Downgoat
 
Can ruby to one-to-many relationships?
 
yeah
this is what this is
the school has_many stories and the story belongs_to the school
(this is very close to how they are represented in the model file)
 
8:56 PM
Huh, so is it possible to do cascade delete when I delete a school?
 
Yes, should I implement that?
 
If it's trivial, sure, but I probably won't be deleting schools very often anyway >_>
 
Yeah I just did it
@Downgoat pull the repo
@betseg What is "evet" and "hayir"
 
@Mendeleev AFAIK yes/no respectively
 
ah
 
9:08 PM
@Mendeleev evet-yes hayır-no (as in, i do/do not want the change in the constitution)
 
oic
 
@betseg to be fair, at least you guys have referendums for constitution changes :P
 
if erdogan's party got 66% of the MPs (i think) they wouldnt even need a referandum, and the election threshold is 10% and in the last election two parties got 11%, so they almost didnt need the referandum
 
9:25 PM
If I get the gold badge do the number of silver badges I have go down?
 
user165474
@WheatWizard I'm pretty sure the number of bronze/silver/gold badges isn't counting tag badges.
 
user165474
gtg, bye
 
Oh ok
thanks
 
i almost dont care about the referandum
global warming is worse
we were under this system anyways, just under another name
 
@HyperNeutrino No, they do count. I have 3 gold non-tag badges and 4 gold badges
@WheatWizard no. It'll stay the same
 
10:00 PM
Is there a (sane, not golfing) language which relies on shell job control (not /proc stuff)?
 
@mınxomaτ I assume the shell languages do?
bash et al
 
Bash does complain if the calling shell doesn't give it job control, but nothing really breaks (any suggestions for further tests?). Whereas some compilers don't even start if e.g. proc isn't mounted.
I guess it would be a problem if the language (or a library) calls back to the system shell for doing stuff. Thinking about PHP etc.
 
10:31 PM
also @Mendeleev /stylesheets (and /scripts) isn't working as it says there is no route: ActionController::RoutingError (No route matches [GET] "/stylesheets/application.css")
 
@Downgoat /stylesheets... shouldn't be there
It should only be in the app. It gets included automatically in the layout.
 
@Mendeleev yeah, it does, but then browser complains:
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (application.css, line 0)
 
if you look at views/layouts/application.html.erb it should stylesheet_link_tag
@Downgoat wat. link?
 
app/assets/stylesheets/application.css exists
 
hmmm
one sec
RAILS_ENV=production rails assets:precompile
@Downgoat
 
10:38 PM
do I need to do this everytime I update the CSS?
 
in production mode, yes. you should switch it to development mode if you want to work on it, it's a lot better for this.
just replace -e production with -e development
 
F, [2017-04-16T22:40:29.928076 #13659] FATAL -- : [caf6aa8b-4a88-43c7-84c9-5f07b37a2b02] ActionController::RoutingError (No route matches [GET] "/assets/application-c3b018a2e60c11f22013c2b6054786b5abe80422cfaeed306586a6e4010f1047.js"):
 
huh.
just switch it to dev mode for now
 
will that fix?
 
for now. there's a deeper problem.
don't forget to submit pull requests
 
10:45 PM
@Mendeleev ok, will submit PR but can we then make stories repo private?
 
why?
afaik .gitignore contains the databases
 
I just don't want to be open source for now
 
all right, I can make it private
what is your email address
 
@Mendeleev contact@vihan.org
 
user165474
I want everyone's opinion on this: Does it make sense for this to be a duplicate of this?
 
10:49 PM
no
 
user165474
I don't think so either.
 
user165474
It has a close vote on it as dupe for whatever reason
 
user165474
(comments)
 
user165474
404
 
10:50 PM
ik
it's private
 
user165474
Oh k
 
user165474
whoops
 
user165474
:P
 
@Downgoat your secret key is missing
 
@Mendeleev ik, I previously had hardcoded beacuse for some reason rails isn't reading the env var
 
10:52 PM
in dev it doesn't read env
 
It's defined in /env/environment and I can see it by doing echo $SECRET_KEY_BASE but doesn't work :/
@Mendeleev I'm still in production
 
oh
@Downgoat should be /etc/environment
 
sorry, that's what I meant
@Mendeleev how to copy database from production to development?
 
just cp
 
ok cool
:D awesome it works!
:O and even the HTML/CSS is working
 
11:02 PM
You might want to customize the /stories/new page and remove the CSRF protection lines
like
remove the thing that blocks the protection
not the protection itself
 
@Mendeleev right now / goes to index.html.erb how can I make it a static page? I think I can put an html in public/ but it still is looking for a template
 
@Downgoat rails generate controller index index
 
@Mendeleev still goes to the template?
 
go to config/routes.rb, at the top after the first line add get 'index/index'
 
it already has that
 
11:08 PM
replace root 'stories#index' with root 'index#index'
then go to app/views
make a new file called index.html.erb
use that
 
ohhh I see how this works
cool
 
just remember, it will be inserted in the template
 
@Mendeleev how do I make it not load jQuery and a bunch of unrelated stylehseets?
index/index is like loading school.css and stories.css
 
You don't want jQuery?
 
jQuery is evil D:
btw, what is turbolinks
 
11:10 PM
link enhancer
look it up
 
hm, ok
 
although it messes with onload
 
Two question: 1) how can I custom script tags to header 2) is it possible to add a common header <div> that is shown across all pages
 
@Downgoat app/views/layouts/application.html.erb
also, select.html is not a thing.
 
@Mendeleev do you know how I can do session variables?
 
11:20 PM
@Downgoat please define
 
I want them to need to select a school before being able to see /stories or write a new story. i.e. redirect them to a /select page to select a school. The school will be placed in cookie and they will redirected back
not sure what is the best way to do such a workflow
 
Huh.
I don't know actually.
 
@Mendeleev can I just delete some of the pages in /view if I don't want them?
 
@Downgoat explain please.
 
for example, if I don't want views/stories/edit.html.erb, can I just delete the file? or do I also need to change some .rb file
 
11:25 PM
First of all, why would you want to remove it? It's the only way to edit a story for now.
Second, yes, if you delete the file the app will respond with 204 No Content. You would need to delete the edit action in the controller...
 
11:40 PM
@Downgoat
 

« first day (2269 days earlier)      last day (2566 days later) »